Which Version Is Correct?

Both are correct.
In most cases it's just a way you write code.
But there are some small differences.
See PHP manual for that:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single
 
good show! seems double quotes are to be used if you have string data,
and single quotes are used for literal translation. wish i'd started learning
php several years ago.

thanx! :D

tsp
 
Use single quotes unless you have a bunch of single quotes in the string. PHP parses single quotes a bit faster b/c it doesn't have to search or replace variables in the string.
 
A single-quoted string does not have variables within it interpreted. A double-quoted string does.
Also, a double-quoted string can contain apostrophes without backslashes, while a single-quoted string can contain unescaped quotation marks.
The single-quoted strings are faster at runtime because they do not need to be parsed.
 
Last edited by a moderator:
Back
Top