PHP echo single quote & double quote confusion

Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

PHP echo single quote & double quote confusion

Post by Neo » Wed Jan 20, 2010 10:12 pm

People especially newbies are sometimes confused with the single and double quotes in echo function. Here is a good example to understand the behaviours of this.

Code: Select all

<?php
$color = "red";
echo "Roses are $color";
echo "<br />";
echo 'Roses are $color';
?>
The output of the code above will be:
Roses are red
Roses are $color
Post Reply

Return to “PHP & MySQL”