1. Home
  2. Computing & Technology
  3. PHP / MySQL

Single or Double Quotes?
Should you use single or double quotes in your code?

By Angela Bradley, About.com

Sometimes people use double quotes in PHP to avoid having to use the period to separate code. For example, you could write:
"I have a $color shirt on today";
Faster however is not always better. A better way to write this code would be:
'I have a ' .$color. ' shirt on today';
Phrasing your code in the second method will result in less chance of error messages, or problems with other programmers deciphering your code.
More PHP / MySQL Quick Tips
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Troubleshooting
  5. Single Quotes PHP - Double Quotes PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.