数据分析师2017-09-30 23:38:59
Why is it okay to use single quotes when constants are stored in variables? - PHP Chinese website Q&A - Why is it okay to use single quotes when constants are stored in variables? - PHP Chinese website Q&A
Take a look around and learn.
阿神2016-12-24 13:19:56
PHP单引号及双引号均可以修饰字符串类型的数据,如果修饰的字符串中含有变量(例$name);最大的区别是: 双引号会替换变量的值,而单引号会把它当做字符串输出。
例如:
<?php $name="string"; echo " 字符串" . '$name'; echo "字符串" . "$name"; ?>
结果:
字符串$name
字符串string
还有重要的一点点:单引号和双引号区别的意义
当所发送的数据中涉及到单引号和双引号时,在打印双引号时使用单引号,反之亦然,如:
echo 'She said,"How are you?"';
print "I'm just ducky.";
希望能帮到你