02 Sep 2008
The strict use of single quotes is preferred—not mandated—and the rule of readability over performance is to be maintained. As an example:
'Short String' . "\n"; "Short String\n";
Either form allowed where the string is short. Where the string is long the first form is required. Where the literal is to be followed by a variable instead of an escaped literal, the first form should prevail:
'Any String ' . $var; NOT "Any String $var"; NOR "Any String {$var}";
In all cases, readability is improved with increased whitespace, squishing stuff together to "save space" makes for a headache when you have to go back and maintain code.
There is never an excuse to quote a variable on its own, e.g. "$var", "{$var}", "{$class->var}", etc.
How about something like,
How about something like, use single quotes when no variables or escaped characters are to be included in the string, double quotes otherwise. Consider using some form of storage for very long strings(that might affect parse times, if you care about parse times) like the template, or a database, or a flat file.