Reply to Re: single quotes, double quotes and "undefined index"

Your name:

Reply:


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']."'";

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация