It seems that you are saying that not using quotes is bad (first), but then later you show that omitting the quotes does not result in an error. Or are you saying that the quotes can be omitted if the array element is being used in a string (between quotes), but generally the quotes around the constant are needed to perform non-string operations?
Thank you, Erik On Friday, January 11, 2002, at 01:06 PM, Philip Olson wrote: >>> $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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]