Page 1 of 1

Using single quotes versus double quotes (explanation?)

Posted: Thu Jan 15, 2009 5:49 pm
by xpiamchris
So i was trying to debug this code:
header('Location: http://secure.mysite.com/managepicture.php?var=$var');

and realized by changing the single quotes to double quotes, it worked... But how do you know when to use single quotes and when to use double quotes?

Best,
Chris

Re: Using single quotes versus double quotes (explanation?)

Posted: Thu Jan 15, 2009 5:51 pm
by andym01480
Single quotes is as is.
Double quotes allows variables like $var to be interpreted for value rather than just as a sequence of characters.

another example

Code: Select all

$hello='Hi';
echo "$hello"; //outputs Hi
echo '$hello'; //outputs $hello