Double quote vs. single quotes in PHP

Posted on November 4 2009 by zemog

Almost always newbies does not care about what is going in “inside the hood” when you are developing a php project. Yes this thing that I will be talking about will not really have a big impact if you are just having small projects. But nonetheless, it is worth talking.

Take this as an example.

$string = “shoutbux”;
echo $string.’ submit your thoughts’;
echo “$string submit your thoughts”;

If you will see both will display the same thing. But PHP manual suggests that

“Parsing variables within strings uses more memory than string concatenation. When writing a PHP script in which memory usage is a concern, consider using the concatenation operator (.) rather than variable parsing.”


Share This Post

Comments are closed.