Forum Moderators: coopster

Message Too Old, No Replies

When to use which quotes

         

Crump

5:30 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



I have been programming PHP for a while, but I never full understood the quotes.

When is it better to use ' ' as opposed to " "?

eelixduppy

5:38 pm on Jun 16, 2006 (gmt 0)



Apparently using single quotes(') is faster than using double, but with the single quotes PHP will not parse variables within the quotes but just output the variable name. If you are going to place variables within a string, you have to use double quotes.

$fish = "blue fish";
echo 'I love $fish'; //prints I love $fish
echo "I love $fish"; //prints I love blue fish
//or
echo 'I love '.$fish;

mcavic

8:52 pm on Jun 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed. I always use double quotes in PHP for that reason. That way, it also allows me to consistently use single quotes for html/javascript output. For example,

print "<table border='1'>";

jatar_k

9:44 pm on Jun 16, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you read this?
[php.net...]