Thursday, June 21, 2012

Difference between single quote and double quote in PHP



Single quote(' ') and double quote (" ")  both specify strings in PHP. But there some difference.
Single quote(' ')  will not  interpret more escape sequences for special characters:
Example
<?php
$mystring='test';
echo '\r\n';
echo '$mystring';
?>
will output
 \r\n$mystring

 Single quote(" ")  will  interpret more escape sequences for special characters:
Example:
 <?php
$mystring='test';
echo "\r\n";
echo "$mystring"
?>
will output
test
 echo "\r\n";  interpret as return key.

No comments:

Post a Comment