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

More from About.com

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

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

All rights reserved.