RE: [PHP] quick question

From: Date: Fri, 11 Jan 2002 18:06:18 +0000
Subject: RE: [PHP] quick question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80220@lists.php.net to get a copy of this message
> > $sql = "SELECT * FROM tablename WHERE > > tablename.column=$_GET['criteria_integer']"; > > > > but unfortunately, this isn't working. On a related note, outside of strings one should always surround keys with quotes, so: $arr = array('a' => 'apple', 'b' => 'banana'); print $arr['a']; // apple print $arr[a]; // apple BUT this is bad Without the quotes is bad because PHP first: a) looks for the constant named 'a' b) if constant 'a' is not found, an error of type E_NOTICE is thrown. So, let's do this: define('a','b'); print $arr['a']; // apple print $arr[a]; // banana (no error) Because constants are not looked for within strings, the following is appropriate: print "an $arr[a]"; // an apple As are: print "an {$arr['a']}"; // an apple print "an ". $arr['a']; // an apple Anyway, maybe that helps explain a few things :) Regards, Philip Olson

« previous php.general (#80220) next »