' 和 &quot 和有什么不一样?在 PHP 中?

2021-12-29 00:00:00 syntax php

可能的重复:
PHP:不同的引号?

简单的问题:

php 中的 ' 和 " 有什么区别?我应该什么时候使用?

What is the difference between ' and " in php? When should I use either?

推荐答案

基本上,单引号字符串是纯文本,几乎没有特殊情况,而双引号字符串具有可变插值(例如 echo "Hello $username";) 以及转义序列,例如 "(换行符.)

Basically, single-quoted strings are plain text with virtually no special case whereas double-quoted strings have variable interpolation (e.g. echo "Hello $username";) as well as escaped sequences such as " " (newline.)

您可以在 PHP 手册中了解有关字符串的更多信息.

You can learn more about strings in PHP's manual.

相关文章