Re: Reasoning behind using quotes for associative array element access?
| From: | Charles Killian | Date: | Fri, 11 Aug 2000 21:48:57 +0000 |
| Subject: | Re: Reasoning behind using quotes for associative array element access? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11419@lists.php.net to get a copy of this message | ||
If you look at it from PHP's perspective and plain text is a CONSTANT.
So if you don't put quotes around the "element" it should assume it's been
defined().
Of course php is smart enough to know if it's plain text and not defined()
assume 'text'.
You are just putting the PHP through more steps if you don't quote the array
elements.
This is only a guess.
Charlie
----- Original Message -----
From: "Christensen, BruceX R" <brucex.r.christensen@intel.com>
To: "PHP mailing list (E-mail)" <php-general@lists.php.net>
Sent: Friday, August 11, 2000 1:53 PM
Subject: [PHP] Reasoning behind using quotes for associative array element
access?
> What's the purpose of having $myarray["element"] be legal, while
> $myarray[element] is "illegal"? When I was first learning PHP, I did it
the
> Perl way, without the quotes. I have since discovered that this is "bad",
> but I don't understand why. It works both ways (albeit with a warning if
> error reporting is turned up above the default), and so I can do something
> like $myarray["value$num"] if necessary, but most of the time,
> $myarray[element] is quicker.
>
> Any hazards of doing it w/o quotes?
>
> Ideas? Rasmus? Zeev?
>
> --Bruce
>
> Bruce Christensen
> Intel Corporation
> brucex.r.christensen@intel.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>