Single Quote :
- The simplest way to specify the string is the single quoted string .
- The single quote treats the string as the plain text .
- It is bit faster than the double quoted string .
Example :
<?php
$variable = “value”;
$output = ‘My $variable will not print!\n’;
print($output);
?>
Output :
My $output will not print!n
Here ,
$variable will not produce any result .
And ,
In order to concatenate you need to use ( . ) operator .
Example for concatenate with single quote and dot operator
<?php
$name = “php”;
echo ‘String with a php variable ‘.$name;
?>
Output as :
String with a php variable is php
Double Quote :
Lets See from the above example :
<?php
$variable = “value”;
$output = “My $variable will not print!\n”;
print($output);
?>
Output as :
My value will not print!n
Here ,
The valye of $variable is replaced by its value “value “.
And ,
In order to concatenate you need to use {} operator .
Example for concatenate with single quote and dot operator
<?php
$name = “is php”;
echo “String with a php variable {$name}”;
Same output as above :
String with a php variable is php
Happy Codding …………………..
Please leave a comment for any query ……………….
To know about Heredoc and Nowdoc please click this here