Using ' to access session variables?

From: Date: Fri, 16 Apr 2004 16:32:11 +0000
Subject: Using ' to access session variables?
Groups: php.general 
Request: Send a blank email to php-general+get-183642@lists.php.net to get a copy of this message
Whats the difference between $_SESSION[foo] and $_SESSION['foo'] I have been using the 's but they seem to be unecessary? I run into trouble if I try something like: $query = " select * from table where (test.id = '$_SESSION['foo']') "; but the following works: $query = " select * from table where (test.id = '$_SESSION[foo]') "; I know there is some way to properly escape characters but is there any reason why I shouldn't just omit the 's? Thanks!

« previous php.general (#183642) next »