To single quote or not to single quote?

If ever in need of some practical information on optimizing PHP code, John Lim’s howto is a great resource. The article has been kept up to date with changes in PHP, and serves as a reminder to focus on what really matters in optimization.

There has been some discussion lately about whether it worthwhile to use single quotes over double quotes in PHP. Yes, it’s faster to use single quotes since PHP doesn’t have to look for variables within a string. But no, it’s not really worth the effort to use single quotes exclusively. Why? Most significantly, the performance gain is neglible (if you need more speed, this isn’t where you’re going to get it). And secondly, if you have to change code (or coding practices), you’re only making it harder to read and creating more work.

I’ve heard people advocate extreme optimization before. My favorite was the tongue-in-cheek school of thought that recommended that all HTML code be parsed so that tags with long names are replaced with shorter ones, and all “unnecessary” whitespace be removed. The browser doesn’t care what your code looks like, and the less whitespace there is, the less data there is to transfer.

---

There are 2 other entries posted on this day.