note 23860 added to language.types.array
| From: | slava at nospam dot trushkin dot net | Date: | Tue, 30 Jul 2002 13:20:54 +0000 |
| Subject: | note 23860 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33989@lists.php.net to get a copy of this message | ||
When using array inside double-quoted string key should be single-quoted
only if you use curly braces around variable like this:
$array = array('key' => 'value');
incorrect syntax:
echo "value = $array['key'] \n";
echo "value = {$array[key]} \n";
first line compiler won't even compile
on second line compiler will consider "key" as contant and will show warning if
error_reporting is E_ALL
correct syntax:
echo "value = $array[key] \n";
echo "value = {$array['key']} \n";
on first line: no curly braces - no quotes
second line: use curly braces - should use quotes
--
http://www.php.net/manual/en/language.types.array.php
http://master.php.net/manage/user-notes.php?action=edit+23860
http://master.php.net/manage/user-notes.php?action=delete+23860
http://master.php.net/manage/user-notes.php?action=reject+23860