note 19295 added to language.types.array
| From: | jpaulomfNO_ at at _SPAM dot terra dot com dot br | Date: | Fri, 22 Feb 2002 13:04:55 +0000 |
| Subject: | note 19295 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26925@lists.php.net to get a copy of this message | ||
There is a strange behavior of arrays within double quotes:
error_reporting(E_ALL);
$arr = array( 'foo' => 'bar', 'etc' => 'other');
//This will make a Parse Error in PHP 4.1.1:
echo "Foo value is $arr['foo']";
//Try instead:
echo "Foo value is ".$arr['foo'];
//or
echo "Foo value is {$arr['foo']}";
//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// THIS will work AND send the warning NOTICE:
echo "Foo value is ".$arr[foo];
echo $arr[foo];
It seems you cannot use the correct syntax within ""s, try the deprecated one and it will
work fine without nor even sending the warning...
Should it work this way? Is it a bug? If yes, does it happens with 4.1.1 only ??
System:
Slack 8.0
Linux 2.4.5
PHP 4.1.1 as a static module of Apache 1.3.22
João Paulo M. Fischer
--
http://www.php.net/manual/en/language.types.array.php
http://master.php.net/manage/user-notes.php?action=edit+19295
http://master.php.net/manage/user-notes.php?action=delete+19295
http://master.php.net/manage/user-notes.php?action=reject+19295