gpt4 book ai didi

php - MySQL 括号?

转载 作者:可可西里 更新时间:2023-11-01 07:47:05 27 4
gpt4 key购买 nike

最近我看到了很多将 SQL 值包含在 {} 中的 PHP/MySQL 问题,例如:

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 {$.

关于php - MySQL 括号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2168160/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com