Page 1 of 1

Re: PHP strings "/' ??

Posted: Sat Aug 08, 2009 6:51 am
by jazz090
to my knowledge, single quotes take up less memory and what you use is a matter of preference. however i know for a fact that executing mysql queries need to be done in double quotes because you use single quotes to define values in mysql:

Code: Select all

mysql_query("INSERT INTO foo VALUES('bar')");

Re: PHP strings "/' ??

Posted: Sat Aug 08, 2009 8:30 am
by frao_0
Also,

$name="John" ;

echo "Hello $name"; // outputs Hello John
echo 'Hello $name'; // outputs Hello $name

Re: PHP strings "/' ??

Posted: Sat Aug 08, 2009 8:33 am
by aceconcepts
The main reason why I use single quotes is because you don't have to escape them unlike double quotes.

Also, like jazz090 mentioned, single quotes are faster to process.