NULL's + current breaks existing scripts
| From: | Stanislav Malyshev | Date: | Mon, 03 Jan 2000 10:30:40 +0000 |
| Subject: | NULL's + current breaks existing scripts | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-8826@lists.php.net to get a copy of this message | ||
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