Re: [PHP] Returning values from a function
Hi: return array( 'string_to_display' = $string_to_display, . ); Best regards 惠新宸 Xinchen Hui http://www.laruence.com/ On 2010/11/15 11:10, Ron Piggott wrote: I am writing a string parsing function. I need to return 3 values from a function: return $string_to_display; return $string_to_parse; return $continue_parsing; I am not sure how to retrieve these variables. The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confusion about the file extension for php interpreter to interpret
Hi: add AddType application/x-httpd-php .Php into httpd.conf or any other config file in apache/conf/extra thanks 惠新宸 Xinchen Hui http://www.laruence.com/ On 11/14/2010 13:29, 肖晗 wrote: Apache defaultly use php interpreter to execute files ended with '.php' extension. How can I change this rule?Can I change the default extension to any arbitrary name? Such as .PHP or .Php and so on. And I am using Ubuntu/Linux, Apache2 and php5. Thanks very much! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require_once
hi: print_r(get_include_path()); thanks; Best regards 惠新宸 Xinchen Hui http://www.laruence.com/ On 10/19/2010 10:46, jim wrote: I'm having a problem including files using Zend Framework. I have in a controller file this require_once models/Member.php; and it doesn't work ,nor does require_once ../models/Member.php; Anyone know what's going on with this? Jim W. -- 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] php5 - website development - what next
On 10/08/2010 22:06, 惠新宸 wrote: test, i can't send mail to lists? thanks On 10/08/2010 22:02, 惠新宸 wrote: Hi: 1. you can be a Software Architect 2. you can abstract common requirements, developed php extension. thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression Problem
Alice Wei wrote: Hi, I have two lines here as follows: 1 -0.123701962557954E+03 0.460967618024691E+02 -0.12354765900E+03 0.46259109000E+02 What I am trying to do here is to only have 1 -0.123701962557954E+03 0.460967618024691E+02 be the output so I can do further processing with it, however, with the code I have in the following, I have both lines in the output. Here is the code: $file = "test.txt"; $fp = fopen($file, "r"); $lines = file($file); foreach($lines as $line_num = $line) { if (preg_match("/([^0-9]+\s+)(\-?\d+\.?\d+(\+?E?\d+)?){2}/", $line)) echo $line; } Could anyone please tell me that even when I specify that the line has to start with [^0-9]+\s with one occurrence, why I still get -0.12354765900E+03 0.46259109000E+02? Thanks a lot for your help. Alice _ Express yourself with gadgets on Windows Live Spaces http://discoverspaces.live.com?source=hmtag1loc=us [^0-9] means not a digital ^[0-9] is the right way.. -- Laruence's Signature 惠 新宸 xinchen.hui | SYS | (+8610)82602112-7974 | :laruence
Re: [PHP] How can an elephant count for nothing?
Jochem Maas wrote: Clancy schreef: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0) returns true; If($string != 0) returns false; If($string === 0) returns false; I know that in this case I should use 'If($string == '')', but I still manage to forget. Can anyone explain clearly why comparing a string with zero gives this apparently anomalous result? it's called auto-casting (or auto-typecasting) and it's 'by design' ... welcome to the world of dynamic typing. try this to see it working: php -r ' var_dump((integer)"elephant"); var_dump((float)"elephant"); var_dump((bool)"elephant"); var_dump((array)"elephant"); var_dump((object)"elephant"); var_dump((bool)(integer)"elephant"); ' you can avoid auto-casting if needed, in a variety of ways: php -r ' $foo = "elephant"; if (!empty($foo)) echo "$foo found!\n"; if (strlen($foo)) echo "$foo found!\n"; if (is_string($foo) strlen($foo)) echo "$foo found!\n"; if ($foo !== "") echo "$foo found!\n"; if ($foo === "elephant") echo "$foo found!\n"; ' those last 2 show how to use 'type-checked' equality testing. because intval("elephant") == 0; intval will convert the string into integer , Strings will most likely return 0 although this depends on the leftmost characters of the string. -- Laruence's Signature 惠 新宸 xinchen.hui | SYS | (+8610)82602112-7974 | :laruence
Re: [PHP] Wierd Variable Initialization
Title: Laruence's Signature register_global = on ? VamVan wrote: So guys, I found some thing strange that happened to me yesterday. Its small but kinda freaked me out. So I have a tokenmap.php that I include include in different configuration files. Some are classes and some are simple php files. So in my tokenmap.php I have declared an array as global. SO $GLOBAL['tokenmap'] = array() As a good programming practice what I did was: require_once('tokenmap.php'); $tokenmap = array(); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); The above displays empty array But when I do this , it works require_once('tokenmap.php'); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); Its kind of wierd for me. I am trying to understand. Can some one shed some light on it for me. Thanks -- 惠 新宸 xinchen.hui | SYS | (+8610)82602112-7974 | :laruence
Re: [PHP] Wierd Variable Initialization
Title: Laruence's Signature register_global = on ? VamVan wrote: So guys, I found some thing strange that happened to me yesterday. Its small but kinda freaked me out. So I have a tokenmap.php that I include include in different configuration files. Some are classes and some are simple php files. So in my tokenmap.php I have declared an array as global. SO $GLOBAL['tokenmap'] = array() As a good programming practice what I did was: require_once('tokenmap.php'); $tokenmap = array(); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); The above displays empty array But when I do this , it works require_once('tokenmap.php'); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); Its kind of wierd for me. I am trying to understand. Can some one shed some light on it for me. Thanks -- 惠 新宸 xinchen.hui | SYS | (+8610)82602112-7974 | :laruence