Home > PHP, Tips > PHP – Quotes or No quotes in associative Array?

PHP – Quotes or No quotes in associative Array?

September 14th, 2006

Our team was having a debate on why we should put a ‘ (single quote) when referencing arrays in php. Well what is the problem if we use $_SESSION[key], instead of $_SESSION['key'].

Well when you think that when encountering non functions or keywords, php tries to evaluate it as a declared constant. So referencing $_SESSION['key'] would be better against $_SESSION[key], unless we have defined the constant key and want to use the value of key.

Categories: PHP, Tips Tags: ,
Comments are closed.