可能重复:
Difference between single quote and double quote string in php回声单和双引号在PHP
嗨,
是什么echo 'Test Data';
和PHP echo "Test Data";
之间的差异。
这两个语句都给了我相同的输出。
可能重复:
Difference between single quote and double quote string in php回声单和双引号在PHP
嗨,
是什么echo 'Test Data';
和PHP echo "Test Data";
之间的差异。
这两个语句都给了我相同的输出。
相信双引号允许变量由值替换:
echo "test = $test";
显示:
测试= 2
echo 'test = $test';
显示:
测试= $测试
单引号字符串不会有变量或逃避解释扩展序列,而双引号字符串会 - 看看输出不同:
$foo = 'bar';
echo 'This is a $foo';
echo "This is a $foo";
因此,单引号字符串稍微“更好”一些,因为解释器不必检查字符串的内容以获取变量引用。
http://www.php.net/manual/en/language.types.string.php –