Re: [PHP] Who can tell me the best php-base webmail?
Joskey- Squirrel Mail is pretty good- www.squirrelmail.org David - Original Message - From: <[EMAIL PROTECTED]> To: "PHP Mail List" <[EMAIL PROTECTED]> Sent: Monday, December 02, 2002 4:30 AM Subject: [PHP] Who can tell me the best php-base webmail? > Thank you for reading my mail! > -- > Who can tell me the best php-base webmail? > I want a webmail for my mail server, > give me a suggest, please! > -- >Joskey Liaus >[EMAIL PROTECTED] > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to give parameters to a console php-script?
Martin- the command line switches are stored in the $_SERVER['argv'] array. E.g. php -q myscript.php4 1000 The value of $_SERVER['argv'][1] in the myscript.php4 script would be 1000. David - Original Message - From: "Martin Thoma" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 02, 2002 5:40 AM Subject: [PHP] How to give parameters to a console php-script? > Hello! > > I start a console app with > > php myscript.php4 (just prints "ok"). > > How can I give parameters to it? I tried: > php myscript.php4 myparameter > php myscript.php4?myparameter > php myscript.php4?param=myparameter > > But always php just returns without doing nothing (not even giving an > error or printing "Ok"!) I'm using PHP 4.2.3. on Windows2000). > > Martin > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] POST/GET using a proxy server
Hi all- how do I modify the following function to work over a proxy server? Thanks for any help. David /* sendToHost * ~~ * Params: * $host - Just the hostname. No http:// or /path/to/file.html portions * $method- get or post, case-insensitive * $path - The /path/to/file.html part * $data - The query string, without initial question mark * $useragent - If true, 'MSIE' will be sent as the User-Agent (optional) * * Examples: * sendToHost('www.google.com','get','/search','q=php_imlib'); * sendToHost('www.example.com','post','/some_script.cgi', * 'param=First+Param&second=Second+param'); */ function sendToHost($host,$method,$path,$data,$useragent=0) { // Supply a default method of GET if the one passed was empty if (empty($method)) { $method = 'GET'; } $method = strtoupper($method); $fp = fsockopen($host, 80); if ($method == 'GET') { $path .= '?' . $data; } fputs($fp, "$method $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); if ($useragent) { fputs($fp, "User-Agent: MSIE\r\n"); } if ($method == 'POST') { fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); } fputs($fp, "Connection: close\r\n\r\n"); if ($method == 'POST') { fputs($fp, $data); } while (!feof($fp)) { $buf .= fgets($fp,128); } fclose($fp); return $buf; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Easiest way to forward email using imap functions?
Hi all- I'm wondering what's the easiest way to forward a message using the imap functions. The emails I want to forward have attachments so I'm hoping there's an easy way to do this. Or do I have to break down the messages and then send via imap_mail_compose()? BTW the email address I want to forward the emails to is on a different server so I wouldn't be able to just do a imap_mail_copy(). Thanks for any input. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Protocol on handling empty checkbox values
Hi all. For a universal form script I'm writing I want to store a 'Y' in a table field if a checkbox is checked and an 'N' if it's not. The problem is that when the form is posted if the checkbox is not checked the checkbox variable is not passed. E.g. If the checkbox is checked, I get $_POST['my_checkbox_var'] == 'Y', but if not $_POST['my_checkbox_var'] is not even set. So what I've been doing is putting the variable names of the checkbox fields into an array, serializing it, and then pass the string as a hidden input on the form. Then in the page that handles the POST I unserialize the array to determine if checkbox fields were passed and then handle accordingly. But I'm wondering is there a better way (or at least a standard way) of doing this? David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protocol on handling empty checkbox values
> I'd use an array on some way, but the other option is to see if the var is > set, else set it to N > > if(isset($_POST['my_checkbox_var'])) { > $_POST['my_checkbox_var'] = 'N'; > } > > > Probably what I'd do is create an array for the possible checkbox values, > then USE THAT ARRAY to build the form. Then I can re-use the array on the > validation script, checking that each element isset()... if they aren't, set > them to 'N'. Yes that's what I was doing- because the form has other elements other than checkboxes I have to distinguish between the checkboxes and the others and hence a separate array for checkboxes. > To throw in a curve-ball, you can set the default value for your MySQL > column to 'N', which means that any value you DON'T write will be 'N', and > those you do will be 'Y'. Great idea! Actually after I posted the question I thought of the same thing :-). This is probably the most elegant way. I am curious though why PHP doesn't just create the variable anyways and just assign it a null value if the box is not checked. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protocol on handling empty checkbox values
> It's not PHP's fault -- it's the CGI/POST specs. The browser is not sending > it through, because that's what it was told to do :) > Ah- got it. That would make sense since it's the browser that's send the form data to the server, and if it doesn't chose to I wonder why the CGI/POST specs are like that- there's probably a good reason? David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protocol on handling empty checkbox values
Doh- just discovered that this won't work for updates (e.g. if value is already = 'Y' and you uncheck the box it'll stay as 'Y'). David > To throw in a curve-ball, you can set the default value for your MySQL > column to 'N', which means that any value you DON'T write will be 'N', and > those you do will be 'Y'. > > > Justin French > > > > > > on 17/08/02 4:24 AM, David Yee ([EMAIL PROTECTED]) wrote: > > > Hi all. For a universal form script I'm writing I want to store a 'Y' in a > > table field if a checkbox is checked and an 'N' if it's not. The problem is > > that when the form is posted if the checkbox is not checked the checkbox > > variable is not passed. E.g. > > > > > > > > > > > > If the checkbox is checked, I get $_POST['my_checkbox_var'] == 'Y', but if > > not $_POST['my_checkbox_var'] is not even set. So what I've been doing is > > putting the variable names of the checkbox fields into an array, serializing > > it, and then pass the string as a hidden input on the form. Then in the > > page that handles the POST I unserialize the array to determine if checkbox > > fields were passed and then handle accordingly. But I'm wondering is there > > a better way (or at least a standard way) of doing this? > > > > David > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Change user agent when using file() or fopen()
How do I change the "browser" name and version presented to the target web server when I use file() or fopen()? E.g. http://foo.bar/foo.html'); ?> The access_log for the web server will show something like: 127.0.0.1 - - [29/Aug/2002:00:08:59 -0700] "GET /foo.html HTTP/1.0" 404 45 "-" "PHP/4.2.2" I want to change "PHP/4.2.2" to something like "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)". I looked in php.ini but couldn't find a setting for this. Anyone know where to set this? Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upgrading PHP on Redhat
Hi all. What's the correct procedure to upgrade PHP (in this case 4.0.6) on a Red Hat system? Usually I just get the PHP tarball compile it myself but for this particular machine I just want to upgrade the Redhat PHP that's on the system. As you guys know Redhat puts its PHP (and Apache) files in different locations- e.g. php.ini is in /etc. I looked for some RPMs but I kept getting failed dependencies when trying to install them- e.g.: # rpm -Uvh php-4.1.2-7.2.4.i386.rpm error: failed dependencies: php = 4.0.6-15 is needed by php-manual-4.0.6-15 php = 4.0.6-15 is needed by php-imap-4.0.6-15 php = 4.0.6-15 is needed by php-ldap-4.0.6-15 php = 4.0.6-15 is needed by php-mysql-4.0.6-15 php = 4.0.6-15 is needed by php-odbc-4.0.6-15 php = 4.0.6-15 is needed by php-pgsql-4.0.6-15 I'm not an expert in using rpm so I'm probably doing something completely wrong??? David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] find all the numeric positions of a character that appears in a string multiple times
Hi guys. What is the best way to find all the numeric positions of a character that appears in a string multiple times? E.g. let's say I have the following string: $str = "http://foo.bar>test"; And I want to parse the string and extract everything between <>. Now if the string only had a single occurrence of "<" and ">" I can use strpos() and substr() to extract it, but how do I do it for multiple occurrences? I suppose I can keep chopping up the string to do this but I'm not sure if that's the best way. Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] find all the numeric positions of a character that appears in a string multiple times
Thanks Kevin- yeah I guess I'll have to chop up the string. David - Original Message - From: "Kevin Stone" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, January 03, 2002 12:30 PM Subject: Re: [PHP] find all the numeric positions of a character that appears in a string multiple times > SPLIT to the rescue! Split tears up your string into lists (arrays) which > you can cycle through and extract normaly. So this is going to look like > hell but here we go... > > $str = "http://foo.bar>test"; > > $str_list1 = split ('<', $str); > // Note: $str_list1 now == array ("a href=http://foo.bar>", "b>test", "/b>", > "/a>") > $a = 0; > for ($i=0; $i { > $str_list2 = split ('>', $str_list1[$i]); > for ($j=0; $j { > if (empty($str_list2[$j])) > { > next; // skip blank indexes... > } > else > { > $str_list[$a] = $str_list2[$j]; // populate results list... > $a++; > } > } > } > > // print it out... > for ($i=0; $i { > echo "$str_list[$i]"; > } > ?> > > > ... GAH! I second thought there's got to be a better way of doing this! > Anyway hope it helps some. > > -Kevin > > > > Hi guys. What is the best way to find all the numeric positions of a > > character that appears in a string multiple times? E.g. let's say I have > > the following string: > > > > $str = "http://foo.bar>test"; > > > > And I want to parse the string and extract everything between <>. Now if > > the string only had a single occurrence of "<" and ">" I can use strpos() > > and substr() to extract it, but how do I do it for multiple occurrences? > I > > suppose I can keep chopping up the string to do this but I'm not sure if > > that's the best way. Thanks. > > > > David > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] find all the numeric positions of a character that appears in a string multiple times
Here's the function I came up with- seems to work: //finds all occurrences of $char in $temp and returns char positions in an array function char_positions($temp, $char) { while (strpos($temp, $char) !== FALSE){ //note the two '==' $found = strpos($temp, $char); $result[] = $found; $temp = substr($temp, $found + 1, strlen($temp)); } for ($i=0; $i 0){ #if not the first element $result[$i] = $result[$i] + $result[$i-1] + 1; } } if (sizeof($result)>0){ return FALSE; }else{ return $result; } } David - Original Message - From: "Kevin Stone" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, January 03, 2002 12:30 PM Subject: Re: [PHP] find all the numeric positions of a character that appears in a string multiple times > SPLIT to the rescue! Split tears up your string into lists (arrays) which > you can cycle through and extract normaly. So this is going to look like > hell but here we go... > > $str = "http://foo.bar>test"; > > $str_list1 = split ('<', $str); > // Note: $str_list1 now == array ("a href=http://foo.bar>", "b>test", "/b>", > "/a>") > $a = 0; > for ($i=0; $i { > $str_list2 = split ('>', $str_list1[$i]); > for ($j=0; $j { > if (empty($str_list2[$j])) > { > next; // skip blank indexes... > } > else > { > $str_list[$a] = $str_list2[$j]; // populate results list... > $a++; > } > } > } > > // print it out... > for ($i=0; $i { > echo "$str_list[$i]"; > } > ?> > > > ... GAH! I second thought there's got to be a better way of doing this! > Anyway hope it helps some. > > -Kevin > > > > Hi guys. What is the best way to find all the numeric positions of a > > character that appears in a string multiple times? E.g. let's say I have > > the following string: > > > > $str = "http://foo.bar>test"; > > > > And I want to parse the string and extract everything between <>. Now if > > the string only had a single occurrence of "<" and ">" I can use strpos() > > and substr() to extract it, but how do I do it for multiple occurrences? > I > > suppose I can keep chopping up the string to do this but I'm not sure if > > that's the best way. Thanks. > > > > David > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Quick regular expressions question / preg_replace
Hi guys. Quick regular expressions question here: I want to match: but not: blah blah Basically I want to wipe out lines beginning with the tag followed immediately by a carriage return. If I do a: str_replace("\r\n", '', $string); It wipes out and the carriage return after blah blah . So I suppose I have to turn to preg_replace, but I'm having a hard time coming up with the right pattern. Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Quick regular expressions question / preg_replace
That's an idea but it would delete the carriage return before it which I don't want to happen. I've tried preg_replace("/^\r\n/", '', $string) + quite a few other variations but no luck :-(. Argh! David - Original Message - From: "Bogdan Stancescu" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 04, 2002 6:20 PM Subject: Re: [PHP] Quick regular expressions question / preg_replace > I suck big time at regular expressions, but have you tried > str_replace("\r\n\r\n", '', $string); ? > > Bogdan > > David Yee wrote: > > > Hi guys. Quick regular expressions question here: > > > > I want to match: > > > > > > > > but not: > > > > blah blah > > > > Basically I want to wipe out lines beginning with the tag followed > > immediately by a carriage return. If I do a: > > > > str_replace("\r\n", '', $string); > > > > It wipes out and the carriage return after blah blah . So I > > suppose I have to turn to preg_replace, but I'm having a hard time coming up > > with the right pattern. Thanks. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Quick regular expressions question / preg_replace
Ah that would do it (just need to double quote the \r\n). Thanks! I just know, however, one of these days I'm gonna need to use preg_replace :-). David - Original Message - From: "Bogdan Stancescu" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 04, 2002 6:46 PM Subject: Re: [PHP] Quick regular expressions question / preg_replace > str_replace("\r\n\r\n", '\r\n', $string); > > David Yee wrote: > > > That's an idea but it would delete the carriage return before it which I > > don't want to happen. I've tried preg_replace("/^\r\n/", '', $string) > > + quite a few other variations but no luck :-(. Argh! > > > > David > > > > - Original Message - > > From: "Bogdan Stancescu" <[EMAIL PROTECTED]> > > To: "David Yee" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Friday, January 04, 2002 6:20 PM > > Subject: Re: [PHP] Quick regular expressions question / preg_replace > > > > > I suck big time at regular expressions, but have you tried > > > str_replace("\r\n\r\n", '', $string); ? > > > > > > Bogdan > > > > > > David Yee wrote: > > > > > > > Hi guys. Quick regular expressions question here: > > > > > > > > I want to match: > > > > > > > > > > > > > > > > but not: > > > > > > > > blah blah > > > > > > > > Basically I want to wipe out lines beginning with the tag > > followed > > > > immediately by a carriage return. If I do a: > > > > > > > > str_replace("\r\n", '', $string); > > > > > > > > It wipes out and the carriage return after blah blah . So > > I > > > > suppose I have to turn to preg_replace, but I'm having a hard time > > coming up > > > > with the right pattern. Thanks. > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] How to call method from another class
If I have a PHP class (let's say it's called ClassA), how do I call a method from another class (ClassB) within ClassA? Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to call method from another class
Got it- thanks Sandeep. David - Original Message - From: "Sandeep Murphy" <[EMAIL PROTECTED]> To: "'David Yee'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, January 28, 2002 11:12 AM Subject: RE: [PHP] How to call method from another class > > first create an instance of class B like this... > > $test = new classB(); > > Now, u can refer to any function or method of classB like this: > > $test->hello(); // where hello() is a method of classB.. > > cheers, > sands > > -Original Message- > From: David Yee [mailto:[EMAIL PROTECTED]] > Sent: segunda-feira, 28 de Janeiro de 2002 17:19 > To: [EMAIL PROTECTED] > Subject: [PHP] How to call method from another class > > > If I have a PHP class (let's say it's called ClassA), how do I call a method > from another class (ClassB) within ClassA? Thanks. > > David > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP file checksum function?
Is there a file checksum function available for PHP? I want to use md5_file() but that's only in the CVS version of PHP4. The files I want to derive the checksums for can be quite large (50+ megs) so the faster the function the better (i.e. maybe the function just reads parts of the file file). Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Accessing piped data in PHP shell script
How can I access data/parameters piped into a PHP shell script? E.g: cat foo.txt | php -q myscript.php In this example I want to take the contents of foo.txt and store it into a variable/array in myscript.php. I tried $argv[] but no go. Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Accessing piped data in PHP shell script
Oops, nevermind- I found the answer: $fp = fopen("php://stdin", "r"); while(($buf=fgets($fp, 512)) != false) { $input .= $buf; } echo "$input"; - Original Message - From: "David Yee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 4:30 PM Subject: [PHP] Accessing piped data in PHP shell script > How can I access data/parameters piped into a PHP shell script? E.g: > > cat foo.txt | php -q myscript.php > > In this example I want to take the contents of foo.txt and store it into a > variable/array in myscript.php. I tried $argv[] but no go. Thanks. > > David > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to call method from another class
Thanks Joel. I thought Sandeep meant I should create object A within object B in order to refer to the method in object A, but I guess that won't work. David - Original Message - From: "Joel Boonstra" <[EMAIL PROTECTED]> To: "Sandeep Murphy" <[EMAIL PROTECTED]> Cc: "'David Yee'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, January 28, 2002 12:07 PM Subject: RE: [PHP] How to call method from another class > > first create an instance of class B like this... > > > > $test = new classB(); > > > > Now, u can refer to any function or method of classB like this: > > > > $test->hello(); // where hello() is a method of classB.. > > That's not what the original question was, though. David (I think, unless > I got my nested replies wrong), was looking to call a method of ClassA > with an object of ClassB: > > > > If I have a PHP class (let's say it's called ClassA), how do I call a > > > method from another class (ClassB) within ClassA? Thanks. > > The answer to this question, unless my OOP theory is gone, is that you > can't, unless ClassB is an extension of classA. > > So if you have: > > class ClassA { > // some vars > function get_contents() { > // some stuff > return $something; > } > } > > and then: > > class ClassB extends ClassA { > // some vars > function display_contents() { > print $this->get_contents(); > } > } > > Then you're good. Otherwise, I don't think it's possible... > > -- > [ joel boonstra | [EMAIL PROTECTED] ] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] flush() doesn't seem to work for Windows PHP shell script
Hi. I have a PHP shell script running on Windows that I would like to display status on where it's at in the code because it takes a long time to finish. Using flush() doesn't seem to work as all the status messages still don't output to screen until the script finishes running even though I'm doing flush() right after echo. Is there another way to get status messages while the script is running? Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick array question
Hi. Is there an array function that deletes an array element (that's not at the beginning or the end of the array) and return the resultant array? E.g. this is what I want to do: $a = array(1, 2, 3, 4, 5); $b = array_element_delete_function($a, 2); $b now has 4 elements with the following values: (1, 2, 4, 5) Thanks. David
Re: [PHP] Quick array question
That doesn't seem to do what I want. That would only unset the value for the element, but the element is still there. E.g. $a = array(1,2,3,4,5) unset($a[2]); $a now = (1, 2, NULL, 4, 5), but I want (1, 2, 3, 4). David - Original Message - From: "Matt Williams" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, October 30, 2001 10:49 AM Subject: RE: [PHP] Quick array question > Just found this in the manual notes > > http://www.php.net/manual/en/ref.array.php > > To delete an element from an array in an easy way, use > unset($array["element"]);... > > Funny those... manuals > > M: > > > -Original Message- > > From: David Yee [mailto:[EMAIL PROTECTED]] > > Sent: 30 October 2001 19:03 > > To: [EMAIL PROTECTED] > > Subject: [PHP] Quick array question > > > > > > Hi. Is there an array function that deletes an array element > > (that's not at the beginning or the end of the array) and return > > the resultant array? E.g. this is what I want to do: > > > > $a = array(1, 2, 3, 4, 5); > > > > $b = array_element_delete_function($a, 2); > > > > $b now has 4 elements with the following values: (1, 2, 4, 5) > > > > Thanks. > > > > David > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Quick array question
Got it- thanks Philip. David - Original Message - From: "Philip Olson" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, October 30, 2001 11:27 AM Subject: Re: [PHP] Quick array question > Check out this post: > > http://marc.theaimsgroup.com/?l=php-general&m=100096614905023 > > Which reads: > > Here's an example using unset() and array_splice(), notice the subtle > difference: > > > $foo = array('a','b','c'); > > unset($foo[1]); > > print_r($foo);// [0] => a [2] => c > > $bar = array('a','b','c'); > > $piece = array_splice ($bar, 1 ,1); > > print_r($piece); // [0] => b > > print_r($bar);// [0] => a [1] => c > > ?> > > Okay, no need to check the old post now :) Check out : > > http://uk.php.net/array_slice > http://uk.php.net/array_splice > > regards, > Philip Olson > > > On Tue, 30 Oct 2001, David Yee wrote: > > > That doesn't seem to do what I want. That would only unset the value for > > the element, but the element is still there. E.g. > > > > $a = array(1,2,3,4,5) > > > > unset($a[2]); > > > > $a now = (1, 2, NULL, 4, 5), but I want (1, 2, 3, 4). > > > > David > > > > - Original Message - > > From: "Matt Williams" <[EMAIL PROTECTED]> > > To: "David Yee" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Sent: Tuesday, October 30, 2001 10:49 AM > > Subject: RE: [PHP] Quick array question > > > > > > > Just found this in the manual notes > > > > > > http://www.php.net/manual/en/ref.array.php > > > > > > To delete an element from an array in an easy way, use > > > unset($array["element"]);... > > > > > > Funny those... manuals > > > > > > M: > > > > > > > -Original Message- > > > > From: David Yee [mailto:[EMAIL PROTECTED]] > > > > Sent: 30 October 2001 19:03 > > > > To: [EMAIL PROTECTED] > > > > Subject: [PHP] Quick array question > > > > > > > > > > > > Hi. Is there an array function that deletes an array element > > > > (that's not at the beginning or the end of the array) and return > > > > the resultant array? E.g. this is what I want to do: > > > > > > > > $a = array(1, 2, 3, 4, 5); > > > > > > > > $b = array_element_delete_function($a, 2); > > > > > > > > $b now has 4 elements with the following values: (1, 2, 4, 5) > > > > > > > > Thanks. > > > > > > > > David > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Quick array question
Well for that example I'm using 0 as the index for the first element of the array, so deleting element #2 results in 3 being deleted. BTW to correct myself in the second example I gave I want: $a = (1,2,4,5) instead of (1,2,3,4). > $a = array(1,2,3,4,5) > > unset($a[2]); > > $a now = (1, 2, NULL, 4, 5), but I want (1, 2, 3, 4). Thanks. David - Original Message - From: "Sam Masiello" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]> Sent: Tuesday, October 30, 2001 10:53 AM Subject: Re: [PHP] Quick array question > > Very interesting delete function.. > > I assume $b should have values (1,3,4,5), not (1,2,4,5) :) > > --Sam > > > > - Original Message - > From: "David Yee" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, October 30, 2001 2:03 PM > Subject: [PHP] Quick array question > > > Hi. Is there an array function that deletes an array element (that's not at > the beginning or the end of the array) and return the resultant array? E.g. > this is what I want to do: > > $a = array(1, 2, 3, 4, 5); > > $b = array_element_delete_function($a, 2); > > $b now has 4 elements with the following values: (1, 2, 4, 5) > > Thanks. > > David > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Can PHP take input from the command prompt interactively?
Can I write a command line PHP script like the following: php -q test.php Output: == 1)choice A 2)choice B 3)choice C Please enter an option: 1 == Thanks. David
[PHP] PHP as a web browser?
Is it possible to have PHP act like a web browser, accept cookies and post data (for login)? I'm not sure exactly where to start- I know you can use fopen/file to retrieve url's but I'm not too sure about the other steps. I would like to write and run such a php script as a cron job and have it do something like log into my web-based email account, retrieve emails, process them, save them locally, and then delete them on the server. Thanks for any help. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] if(isset($a)) vs if($a)
Hi. What is the difference between: if(isset($a)) and if($a) ??? Thanks. David
[PHP] APC - is it working?
I just installed APC (Alternative PHP Cache). How do I know it's loaded/running/working? Thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Best way to duplicate tables to another DB using PHP
Hi guys. What do you suggest is the best (fastest, most efficient) way to duplicate a table from one database to another using PHP? I have a windows machine setup with ODBC for this old school DB (Pervasive SQL 7) and I would like to duplicate some of the tables into a Linux box with MySQL for some datawarehousing purposes. The largest table is about 30K records. I'm not sure if something like a "select *" and then doing a foreach record insert into MySQL would be the best way. Thanks for any suggestions. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to duplicate tables to another DB using PHP
mysqldump would work pretty well if the source DB is mysql, but it's a DB I have to access via ODBC on a windows box instead. And this particular DB doesn't seem to have a command line interface to export a table that I can call from PHP. David - Original Message - From: sagar N Chand To: David Yee Sent: Wednesday, October 03, 2001 6:09 AM Subject: Re: [PHP] Best way to duplicate tables to another DB using PHP use mysql statement mysql_dump thru php. /sagar - Original Message - From: David Yee To: [EMAIL PROTECTED] Sent: Wednesday, October 03, 2001 2:52 AM Subject: [PHP] Best way to duplicate tables to another DB using PHP Hi guys. What do you suggest is the best (fastest, most efficient) way to duplicate a table from one database to another using PHP? I have a windows machine setup with ODBC for this old school DB (Pervasive SQL 7) and I would like to duplicate some of the tables into a Linux box with MySQL for some datawarehousing purposes. The largest table is about 30K records. I'm not sure if something like a "select *" and then doing a foreach record insert into MySQL would be the best way. Thanks for any suggestions. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to duplicate tables to another DB using PHP
Nope- nothing useful yet anyways :-). I guess maybe the only thing to do is to select different ranges for the table (if it's too big) instead of a select with no where clause. Now to think of it I guess you can even select one record at a time sequentially if the pk is integer based. Then you can do something like: for ($i=0; i++; i<$num_rows_in_table){ $q="select * from my_table where id = $i"; $result=odbc_exec($connect, $q); etc. (e.g. insert into the target mysql DB/table) } David - Original Message - From: "Joseph Koenig" <[EMAIL PROTECTED]> To: "David Yee" <[EMAIL PROTECTED]> Sent: Wednesday, October 03, 2001 6:47 AM Subject: Re: [PHP] Best way to duplicate tables to another DB using PHP > David, > > Did you get any responses on this post? I'm actually looking at a very > similiar situation and thinking the exact same thing. I've done a > "select *" and then a while loop before to accomplish this, but with dbs > where the largest table was about 1K rows. Big difference. Please let me > know if you get any responses or find anything out. Thanks, > > Joe > > David Yee wrote: > > > > Hi guys. What do you suggest is the best (fastest, most efficient) way to > > duplicate a table from one database to another using PHP? I have a windows > > machine setup with ODBC for this old school DB (Pervasive SQL 7) and I would > > like to duplicate some of the tables into a Linux box with MySQL for some > > datawarehousing purposes. The largest table is about 30K records. I'm not > > sure if something like a "select *" and then doing a foreach record insert > > into MySQL would be the best way. Thanks for any suggestions. > > > > David > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Check for parse errors right after edit
Hi- what's the best way to automatically check for parse errors after editing a php script with vi or vim? I suppose that "php -l name_of_script" can be ran after exiting, but I wouldn't want that command to be ran after running vim everytime. Or maybe there's a plugin for vim that will do this? Thanks for any input. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Detecting case change?
Hi- how can I find the character postion in a string right before the first case change? Is there a function out there that already does this? E.g. passing the string "WebApplication" to this function would return the number 2. Thanks for any input. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Detecting case change?
That'll work- didn't realize you can compare strings like that in PHP- thanks guys. David -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, July 21, 2005 3:38 PM To: Philip Hallstrom Cc: David Yee; PHP-General Subject: Re: [PHP] Detecting case change? On Thu, 2005-07-21 at 18:30, Philip Hallstrom wrote: > > Hi- how can I find the character postion in a string right before the first > > case change? Is there a function out there that already does this? E.g. > > passing the string "WebApplication" to this function would return the number > > 2. Thanks for any input. > > I can't think of a function that does this, but something like this > should work. Not sure how efficient it is to constantly call substr() > on the string. Might be better to split it up into an array to start > with. Or there might be a "get character at" function, but I don't see > it right now... > > $word = "WebApplication"; > $length = strlen($word); > > for ( $i = 1; $i < $length; $i++ ) { > $a = substr($word, $i - 1, 1); > $b = substr($word, $i, 1); Just in case you're not aware... you can loop over a strings characters using the string index notation: $length = strlen( $word ); for( $i = 1; $i < $lengthl $i++ ) { $a = $word{$i - 1}; $b = $word{$i}; } Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP mysql data result set compression
Hi all- is there a way have a large data result set from MySQL compressed? E.g. I have a table with over a million rows of data that I want to do a "select * from " on and then take that result, do some field/data manpulation, and then insert row-by-row to another table. The problem is the result of the query is so big that it's casuing PHP to swap to disk, causing things to slow to a crawl. Doing a "show processlist" on the mysql console shows that "Writing to net" is the state of the running "select * from " query. I tried adding the flag "MYSQL_CLIENT_COMPRESS" to both mysql_pconnect() and mysql_connect() but it doesn't seem to do any compression (I can tell by the size of the running php memory process). Any ideas would be appreciated- thanks. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP mysql data result set compression
Thanks guys- I think I'll have to do multiple queries using LIMIT as Geoff suggested since apparently mysql_unbuffered_query() would lose the result set of the "select * from" query once I run the insert query. I'm still not sure why the MYSQL_CLIENT_COMPRESS didn't seem to have an effect, however. David -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Monday, February 06, 2006 4:16 PM To: David Yee Cc: 'php-general@lists.php.net' Subject: Re: [PHP] PHP mysql data result set compression Hi David, See http://www.php.net/mysql_unbuffered_query It won't load the whole lot into memory before returning it to php. David Yee wrote: > Hi all- is there a way have a large data result set from MySQL compressed? > E.g. I have a table with over a million rows of data that I want to do a > "select * from " on and then take that result, do some field/data > manpulation, and then insert row-by-row to another table. The problem is > the result of the query is so big that it's casuing PHP to swap to disk, > causing things to slow to a crawl. Doing a "show processlist" on the mysql > console shows that "Writing to net" is the state of the running "select * > from " query. I tried adding the flag "MYSQL_CLIENT_COMPRESS" to both > mysql_pconnect() and mysql_connect() but it doesn't seem to do any > compression (I can tell by the size of the running php memory process). Any > ideas would be appreciated- thanks. > > David > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP mysql data result set compression
Thanks guys for clarifying the compression aspect. Using mysql_unbuffered_query w/ multipe conenctions sounds nice and simple- though would this method mean more disk access than multiple limit queries? As far as speed goes I imagine if I load as big of a dataset as possible into physical memory w/o disk swapping then that would be the fastest way to do this? David -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Monday, February 06, 2006 4:50 PM To: David Yee Cc: 'php-general@lists.php.net' Subject: Re: [PHP] PHP mysql data result set compression Hi David, From the comments on unbuffered_query: However, when using different db connections, it all works ofcource ... So create a second db connection and when you run the insert use that instead: $result2 = mysql_query("insert blah", $dbconnection_two); client-compress will compress the data on the way to php but then it has to be uncompressed etc (this won't affect much if you're doing it to a local mysql server though, it's more for network servers). David Yee wrote: > Thanks guys- I think I'll have to do multiple queries using LIMIT as Geoff > suggested since apparently mysql_unbuffered_query() would lose the result > set of the "select * from" query once I run the insert query. I'm still not > sure why the MYSQL_CLIENT_COMPRESS didn't seem to have an effect, however. > > David > > -Original Message- > From: Chris [mailto:[EMAIL PROTECTED] > Sent: Monday, February 06, 2006 4:16 PM > To: David Yee > Cc: 'php-general@lists.php.net' > Subject: Re: [PHP] PHP mysql data result set compression > > > Hi David, > > See http://www.php.net/mysql_unbuffered_query > > It won't load the whole lot into memory before returning it to php. > > David Yee wrote: > >>Hi all- is there a way have a large data result set from MySQL compressed? >>E.g. I have a table with over a million rows of data that I want to do a >>"select * from " on and then take that result, do some field/data >>manpulation, and then insert row-by-row to another table. The problem is >>the result of the query is so big that it's casuing PHP to swap to disk, >>causing things to slow to a crawl. Doing a "show processlist" on the > > mysql > >>console shows that "Writing to net" is the state of the running "select * >>from " query. I tried adding the flag "MYSQL_CLIENT_COMPRESS" to both >>mysql_pconnect() and mysql_connect() but it doesn't seem to do any >>compression (I can tell by the size of the running php memory process). > > Any > >>ideas would be appreciated- thanks. >> >>David >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php