Items within single quotation marks are treated literally. Items within double quotation marks are extrapolated (that is, a variable’s name is replaced with its value).
From my point of view, if I were to comply with this rule, I would end up with messy code.
In the example below, there is a mixture of single and double quotation marks. In my opinion this looks tremendously ugly.
<?php
$name='John';
echo '<p>Hello '.$name.', how are you?</p>'."\n"; // Hello John, how are you?
?>
Is it perfectly acceptable to re-write the code as follows?
<?php
$name="John";
echo "<p>Hello ".$name.", how are you?</p>\n"; // Hello John, how are you?
?>
Now you can see that I have used double quotation marks for anything that requires quotation marks. I think this looks much neater. I am guessing that it takes slightly longer to process the script this way because PHP has to figure out whether to extrapolate everything between double quotation marks. Is this really a problem? Please post your thoughts and opinions.