Hi,
Is it desirable, necessary or a bad idea to double quote variables in key. Is this a good or bad idea? $array["$a"]
I get that $array['a'] is a good idea, but not sure if that concept extends to variables. Pros and cons please?
Thx!
quoting keys
Moderator: General Moderators
-
php_silicon_valley
- Forum Newbie
- Posts: 3
- Joined: Mon May 12, 2008 5:28 pm
Re: quoting keys
oh my gosh pleeeeeeeeeeeeeeeeease help-- my manager
is after me on this!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: quoting keys
I think quoting variables (e.g., $array["$a"]) that are not to be expanded in a larger string is not a good practive. mainly it is simply not necessary (i.e., "$a" == $a). The confusion is perhaps because with string literal keys should always be quoted (e.g., $array['a']) but unquoted keys was once allowed.
(#10850)
-
php_silicon_valley
- Forum Newbie
- Posts: 3
- Joined: Mon May 12, 2008 5:28 pm
Re: quoting keys
Thx!!!! 