Re: [PHP4BETA] NULL's + current breaks existing scripts
| From: | Andi Gutmans | Date: | Mon, 03 Jan 2000 21:13:48 +0000 |
| Subject: | Re: [PHP4BETA] NULL's + current breaks existing scripts | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-8868@lists.php.net to get a copy of this message | ||
This is fixed now although I wouldn't call this good programming. Rather you should check for NULL having been returned from current() (or use each() which was meant to replace next()/current() and friends)
Andi
At 12:30 PM 1/3/00 +0200, Stanislav Malyshev wrote:
I understand that new type NULL was entered recently. And current() returns NULL when end of the array is reached. This behaviour breaks some scripts (including PHPLIB 7.2), in the following way: This works: <? $a = array(); next($a); var_dump(current($a)); $x = array("a"); echo $x[current($a)]; ?> Says: NULL <br> <b>Warning</b>: Illegal offset type in <b>-</b> on line <b>6</b><br> That means you can't use NULL as index in array. But you can use it if $x is undefined - script works if you take out $x assignment. This is weird and inconsistent. And I'd say $array[NULL] should be anlways empty or NULL or whatever but not an error, if you want various functions to return NULL on "can't do this" condition. Or lots of exiting scripts will be broken. -- Stanislav Malyshev stas@zend.com +972-3-6139665 -- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net For additional commands, e-mail: php4beta-help@lists.php.net To contact the list administrators, e-mail: php4beta-admin@lists.php.net--- Andi Gutmans <andi@zend.com> http://www.zend.com/