$a="something";
echo ' <div id="content">$a, but not sure how to do it</div>'
How can I print $a
's value inside echo?
$a="something";
echo ' <div id="content">$a, but not sure how to do it</div>'
How can I print $a
's value inside echo?
echo " <div id=\"content\">$a, but not sure how to do it</div>";
Please read the difference between single and double quotes in PHP.
echo "<div id=\"content\">" . $a . ", but not sure how to do it </div>";
The \'s are escape sequences that allow you to have quotation marks within strings (otherwise they would terminate the string). The .'s are concatenation.
there are many ways
1) use " instead of '
echo " <div id='content'>$a, but not sure how to do it</div>"
2) use {} with " if you are want to print something complex and want your editor to format it correctly. most of the time i use it with arrays or when calling a function ex. {$arr['a']} instead of $arr['a'].
echo " <div id='content'>{$a}, but not sure how to do it</div>"
3) just do this
echo ' <div id="content">' . $a . ', but not sure how to do it</div>'