Is there more elegant way of escaping array elements:
mysql_开发者_开发技巧query("SELECT * from mytable WHERE name = '".$someArray['somename']."'");
Something more like
mysql_query("SELECT * from mytable WHERE name = '$myname'");
So avoiding the annoying '". ."'"
You can use:
mysql_query("SELECT * from mytable WHERE name = '{$someArray['somename']}'");
You can actually do:
mysql_query("SELECT * from mytable WHERE name = '{$foo[bar]}'");
But I would advise against it or any other parsed string, it's slower than concatenation and is much harder to read in some IDEs.
$myname = $someArray['somename'];
mysql_query("SELECT * from mytable WHERE name = '$myname'");
精彩评论