When use single quote and when double quote
Posted: Wed Apr 26, 2006 4:33 am
This is a newbie question.
I began to use PHP one month ago.
I found in many cases, single quote and double quote are interchangable just like below.
$var='avalue';
or
$var="avalue";
When a double quote is needed to be embeded into another double quote, sometimes I change the double quote into single one and it's ok. Sometimes I use backslash before the embeded double quote, it also works.
echo "<input name='submit' value='submit' />";
or
echo "<input name=\"submit\" value=\"submit\" />";
I'd like to know what's the different use case for single quote and double quote.
Thanks!
I began to use PHP one month ago.
I found in many cases, single quote and double quote are interchangable just like below.
$var='avalue';
or
$var="avalue";
When a double quote is needed to be embeded into another double quote, sometimes I change the double quote into single one and it's ok. Sometimes I use backslash before the embeded double quote, it also works.
echo "<input name='submit' value='submit' />";
or
echo "<input name=\"submit\" value=\"submit\" />";
I'd like to know what's the different use case for single quote and double quote.
Thanks!