加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – MySQL Brackets?

发布时间:2020-12-13 22:07:03 所属栏目:PHP教程 来源:网络整理
导读:我已经看到很多 PHP / MySQL问题在{}中包含了SQL值,例如: SELECT * FROM table WHERE field LIKE '{$value}'; 那是怎么回事?它甚至有效吗?为什么这么多人会使用这种奇怪的(至少对我而言)语法? 解决方法 从 php.net开始: Complex (curly) syntax This is
我已经看到很多 PHP / MySQL问题在{}中包含了SQL值,例如:

SELECT * FROM table WHERE field LIKE '{$value}';

那是怎么回事?它甚至有效吗?为什么这么多人会使用这种奇怪的(至少对我而言)语法?

解决方法

从 php.net开始:

Complex (curly) syntax

This isn’t called complex because the
syntax is complex,but because it
allows for the use of complex
expressions.

In fact,any value in the namespace can be included in a string with this syntax. Simply write the expression the same way as it would appear outside the string,and then wrap it in { and }. Since { can not be escaped,this syntax will only be recognised when the $immediately follows the {. Use {$to get a literal {$.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读