Would you initialize your strings with single quotes or double quotes?

Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution

Questions by illahi

Showing Answers 1 - 24 of 24 Answers

anildbest

  • Jan 5th, 2008
 

Single quote strings are executed faster than double quotes
When we use single quote for string then php will not parse the things between that quote. It simply assign as it is.
But when we use double quotes then it will parse for variables and other things between double quotes.

If the string is enclosed in double-quotes, PHP understands more escape sequences for special characters. Escape sequences for special characters will not be expanded when they occur in single quoted strings.

  Was this answer useful?  Yes

evantanski

  • Jan 7th, 2012
 

It's always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.

  Was this answer useful?  Yes

Murali

  • Apr 4th, 2012
 

double quotation

  Was this answer useful?  Yes

mart0

  • Feb 5th, 2014
 

Single quotes for performance, no matter if there are variables or not!

  Was this answer useful?  Yes

Sachin

  • Jun 20th, 2014
 

Single quotes will print the statement as a literal but double quotes prints the value for the variables also.....

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions