note 49379 added to language.types.array
| From: | php-general at lists dot php dot net | Date: | Wed, 26 Jan 2005 06:35:44 +0000 |
| Subject: | note 49379 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84003@lists.php.net to get a copy of this message | ||
Hi all
Look at the code:
<?php
error_reporting(E_ALL);
$a = array(
"b" => array(
"c" => "d"
)
);
$e = $a['b']['c']['r'];
echo "\$e = " . $e . "<br>\n";
$f = $a['x']['y']['z'];
echo "\$f = " . $f . "<br>\n";
$g = $a['b']['c'];
$gg = $g['r'];
echo "\$g = " . $g . "<br>\n";
echo "\$gg = " . $gg . "<br>\n";
?>
Look at the result:
$e = d
Notice: Undefined index: x in D:\apache\Apache2\htdocs\shop\_test_rezygnacji.php on line 15
$f =
$g = d
$gg = d
Now, please tell me:
Why PHP returns notice for undefinex index 'x' for $f, but not for $e and not for $gg???
As you can see, PHP returns BAD VALUE "d" letter!!! for $e and for $gg (even if temporary
variable $g is used). There is no error or warning!!!?
Do the PHP check only first-level element in array for index in array? Why not second, third etc. ?
Is this not an error in PHP?
In my oppinion it is.
Bad.
Thx
Sir_Fred
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49379
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49379&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49379&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49379&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49379&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49379&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49379&report=yes
Search -- http://master.php.net/manage/user-notes.php