Re: foreach with null
| From: | Jani Taskinen | Date: | Mon, 24 Oct 2005 22:49:40 +0000 |
| Subject: | Re: foreach with null | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19711@lists.php.net to get a copy of this message | ||
Will the patch make it silently ignore also empty string and 0?
If not, -1. (what's with null being suddenly equal to empty array? :)
--Jani
On Tue, 25 Oct 2005, Marcus Boerger wrote:
Hello internals, i would like to change foreach a tiny bit. Actually i don't like the warning when using foreach with null. marcus@zaphod /usr/src/php-cvs $ php -r '$n=NULL; foreach($n as $v);' make: `sapi/cli/php' is up to date. Warning: Invalid argument supplied for foreach() in Command line code on line 1 marcus@zaphod /usr/src/php-cvs $ php -r 'foreach(NULL as $v);' make: `sapi/cli/php' is up to date. Warning: Invalid argument supplied for foreach() in Command line code on line 1 The way we use NULL in PHP should result in no warning here. The patch for this can be found here: http://php.net/~helly/php/ext/ze2/ze2-foreach-null-20051025.diff.txt It was made with head but applies to 5.1 as well. Any opinions? Best regards, Marcus-- Give me your money at @ <http://pecl.php.net/wishlist.php/sniper> Donating money may make me happier and friendlier for a limited period! Death to all 4 letter abbreviations starting with P!