PHP Curly括号,这段代码的含义 [英] PHP Curly bracket, what's meaning in this code
问题描述
我有以下代码(要从数据库中获取查询,请参见 MyBB 源代码):
I have this code (for getting a query from database, in MyBB source):
$query = "SELECT ".$fields." FROM {$this->table_prefix}{$table}";
我的问题是:{$table}
是什么意思? $ table和{$table}
({}
是什么意思)之间有什么区别?
My question is: What's meaning of {$table}
? and what the difference between $table and {$table}
(what's meaning of {}
)??
谢谢...
推荐答案
花括号只是将变量名与文本的其余部分(以及其他变量名)隔离.通常,出于一致性考虑,使用此语法.当您的变量会碰到其他字母时,有时是有必要的,但是许多程序员一直在使用它,这样他们就不必思考是否有必要.
The braces simply sequester the variable names from the rest of the text (and other variable names). Generally, this syntax is used for consistency's sake; it's sometimes necessary when you have variables that run into other letters, but many programmers use it all the time so that they never have to think about whether it's necessary.
请参见文档.
这篇关于PHP Curly括号,这段代码的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!