double quotes interploats the variables, eg
PHP Code:
$var = robo;
echo 'hi, my name is $var';
// prints hi, my name is $var
echo "hi, my name is $var";
// prints hi, my name is robo
And a \ escapes the next chracter to be process as PHP, say you wrote:
echo "<a href="home.htm">Go home</a>";
You'll get an error 'cos PHP stops echoing after the second quote behind href= and doesn't know what to do with the test following it, so you have to go:
echo "<a href=\"home.htm\">Go home</a>";
This will give you the correct link.
And as you know, \n makes a new line, but if you really want to print "\n" on the screen, you'll have to go:
echo "\\n";
Things get slightly messy when you want to print say part of an array like $array[1][0] along with html code using echo, you'll go:
//$array[1][0] gives home.htm
echo "<a href=\"" . $array[1][0] . "\">Go home</a>";
Hope that helped you a bit.
Bookmarks