' 和 &quot 和有什么不一样?在 PHP 中? [英] What is the difference between ' and " in PHP?

查看:23
本文介绍了' 和 &quot 和有什么不一样?在 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.

这篇关于' 和 &quot 和有什么不一样?在 PHP 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆