To “‘” or Not to ‘”‘?

When I write code in PHP, the amount of time I waste deciding whether to use single quotes around something or double quotes around something, or in deciding that something I started with single quotes (thinking it would be a simple string) should be converted to double quotes so that I can embed a variable in the string and making the change, or vice versa, while maybe a second or two each time, adds up. Therefore, I’ve decided to just use double quotes all the time. I’m used to escaping the double-quote character when it needs to appear inside a string from C++, so that’s no trouble. Even though I’ll have to escape more characters on average, it’s nicer to have a consistent appearance in the code. Finally, whatever extra processor time it takes to parse double-quoted strings for embedded variables really should be negligible, and if it isn’t, I either shouldn’t be using a scripted language like PHP anyway, or should use one of several PHP compilers which should optimize away scanning within double quotes. So to sum it up, ignoring single-quoted strings saves decision and code-fixing time on my part, leads to more consistent code, and in my humble opinion looks better.

This entry was posted in Uncategorized by . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>