NYCPHP Meetup

NYPHP.org

[nycphp-talk] Stupid Question - difference between using single and double quotes

Scott Mattocks crisscott at netzero.com
Mon Mar 29 10:04:29 EST 2004


A string inside of double quotes is always parsed for execution.  That 
means that php will look inside the string and check for any code that 
can be executed.

A string inside of single quotes is never parsed for execution.  The 
string will just be taken literally and code inside of it will not be 
executed.

$stuff = 'things';
echo "I like $stuff"; // output: I like things
echo 'I like $stuff'; // output: I like $stuff

In general you should use double quotes when you want part of a string 
to be parsed and executed.  You should use single quotes otherwise.

Scott Mattocks

EZ wrote:
> Hi all,
> 
> Been a lurker for a month or two and love this list!
> 
> OK, now that I've buttered you all up... ;-)
> 
> I have never understood the difference between using single quotes (') 
> and double quotes (") in my code other than for nesting purposes and (I 
> may be getting the name wrong) string literals and when including 
> variables in strings.
> 
> Can anyone shed light on the proper use of single and double quotes for me?
> 
> Many thanks!
> 
> EZ
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> 



More information about the talk mailing list