微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – MySQL Brackets?

我已经看到很多 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 {$.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐