Page 1 of 1

quoting keys

Posted: Mon May 12, 2008 5:30 pm
by php_silicon_valley
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!

Re: quoting keys

Posted: Mon May 12, 2008 6:29 pm
by php_silicon_valley
oh my gosh pleeeeeeeeeeeeeeeeease help-- my manager :evil: is after me on this!

Re: quoting keys

Posted: Mon May 12, 2008 7:04 pm
by Christopher
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.

Re: quoting keys

Posted: Tue May 13, 2008 1:00 pm
by php_silicon_valley
Thx!!!! :D