PHP strings "/' ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: PHP strings "/' ??

Post 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')");
frao_0
Forum Commoner
Posts: 27
Joined: Sat Aug 08, 2009 3:52 am
Location: Toulouse, France

Re: PHP strings "/' ??

Post by frao_0 »

Also,

$name="John" ;

echo "Hello $name"; // outputs Hello John
echo 'Hello $name'; // outputs Hello $name
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: PHP strings "/' ??

Post 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.
Post Reply