1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Single or Double Quotes?

Should you use single or double quotes in your code?


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.
Related Video
Basic PHP Syntax
Using PHP With HTML

©2014 About.com. All rights reserved.