|
Posted by Markus on 07/13/07 21:29
Michael Fesser schrieb:
> .oO(bill)
>
>> I am trying to write clean code but keep having trouble deciding
>> when to quote an array index and when not to.
>
> Literal array indexs always have to be quoted, unless the entire array
> is embedded in double-quoted string without using curly syntax:
>
> print $foo['bar'];
>
> print "hello $foo[bar]";
>
> print "hello {$foo['bar']}";
>
> All correct.
Additionnally, if you want to be safe, you can just concatenate the string:
$sql = "SELECT * FROM foo WHERE bar='".$_SESSION['bar']."'";
Navigation:
[Reply to this message]
|