The Quest for Quote Consistency


Double quotes or single quotes? That is the question.

After running down a problem with JSON being passed in a hidden field of HTML begin generated by PHP, I’ve come to a new (to me) coding rule for which type of quote to start out using:

  • Double quotes by default for server code (e.g. PHP) and data exchange (e.g. JSON).
  • Single quotes by default for client code (e.g. HTML and JavaScript for web, C and Java for apps).
  • Escape with a backslash (\”) as needed.

Example: echo “<table id=’users’><tr><td>”;

More discussion at

Whether ’tis nobler in the mind to suffer the bugs and hacks of inconsistent coding, or to take arms against a sea of quotation marks, and by standardizing, end them in confusion? Bill S.

View original post


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s