php是'包含'一个函数还是一个声明? [英] Is php's 'include' a function or a statement?
问题描述
网上有很多这两个例子。 php手册说include()语句[...],这似乎是矛盾的 - 如果它是一个声明,它不应该没有括号吗?
There are plenty of examples of both on the web. The php manual says "The include() statement [...]", which seems contradictory - if it's a statement shouldn't it not have parenthesis?
两者都是这些工作:
include('somefile.php');
include 'somefile.php;
我或其他任何人都应该关心吗?
So should I or anyone else care?
推荐答案
引自手册(我的重点)
因为include()是特殊语言构造,括号在其参数周围需要不。
Because include() is a special language construct, parentheses are not needed around its argument.
这些也是称为特殊表格,包括 echo
和返回
语句。请注意,虽然这些都不是函数,但您仍然可以使用表达式和语句,区别在于前者具有值而后者不具有值。由于包括
, include_once
,需要
和 require_once
都返回一个值( TRUE
如果包含成功),它们可以在表达式中使用。通过这种推理,include语句将是不正确的,但 include
几乎总是用作语句。
These are also called "special forms", and include such things as echo
and return
statements. Note that while none of these are functions, you can still speak of expressions and statements, the difference being the former have a value while the latter don't. Since include
, include_once
, require
and require_once
all return a value (TRUE
if the include was successful), they can be used in expressions. By this reasoning, "include statement" would be incorrect, though include
s are almost always used as statements.
这篇关于php是'包含'一个函数还是一个声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!