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!
When use single quote and when double quote
Moderator: General Moderators
Re: When use single quote and when double quote
Hello,
Take a look here, I think that everything is explained very well.
http://www.netcode.net/tutorials/php_my ... quotes.php
HTH
Zythan
Take a look here, I think that everything is explained very well.
http://www.netcode.net/tutorials/php_my ... quotes.php
HTH
Zythan
I agree with Shiznatix... use them consistantly.
I hate it when people do something like this:
I hate it when people do something like this:
Code: Select all
$var = "I need a $variable inserted here".some_func_goes_here('somevar', "somefoo").'Then some html <div id="blah">'.$foobar."</div>";