Re: associative arrays: usage inside double-quoted strings: documentation gap

From: Date: Sat, 10 Mar 2001 00:12:12 +0000
Subject: Re: associative arrays: usage inside double-quoted strings: documentation gap
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-12145@lists.php.net to get a copy of this message
[reply is in-text] On Fri, 9 Mar 2001, Lars Torben Wilson wrote: > I know, I deleted it. :) The replies all got lost in lala-land 'cause > I didn't see your 'nospam' in time. > > This all needs to be updated in the manual--IMHO that whole section > needs to be overhauled--but I personally don't have the time. The most > important bits you've noted below, with a couple of mistakes: "A couple of" => you mentioned one. (except spelling-mistakes probably... i'm sorry about that) > <snip snap> > > > > > <note section=arrays> > > Named indices > > > > Note that > > a) echo "Value of element foo in array arr is " . $arr[foo] > > a) should be documented as incorrect. It will work, in some > cases. However, since the string index is unquoted, PHP will first > attempt to match it to a keyword before interpreting it as a > string. This will show up if you set error_reporting(E_ALL) in your > script. You should always use quotes on your string indices in PHP. Note that one of the examples in the real doc uses this syntax! (in http://www.php.net/manual/en/language.types.array.php) $a[3]['bar'] = 'Bob'; echo "This will work: " . $a[3][bar]; But you're right, this should not work, because it can be ambibious. If i make an update for that page, will it be committed? I understand you don't have the time (for now) to do it yourself, while these basic-syntax things are IMHO quite important to be documented correctly, even more because it is quite strange how this behaves. The curly brace behavior is even worse documented. > <bla bla bla> Jeroen van Wolffelaar Jeroen@A-Eskwadraat.nl http://www.A-Eskwadraat.nl/~jeroen

« previous php.notes (#12145) next »