Both include('file.php')
and include 'file.php'
work and seem to be interchangeable.
Does anyone know if there is any difference between the two syntaxes? Performance? Introduced in a particular version?
I know if you're going to write include $_SERVER['DOCUMENT_ROOT'] . '/file.php';
include $_SERVER['DOCUMENT_ROOT'] . '/file.php';
it would probably look clearer to write include($_SERVER['DOCUMENT_ROOT'] . '/file.php');
There is no difference. These are 'language constructs'. Syntactically this means that they can be used with or without braces. An example is echo
statement.
echo("hello");
and echo "hello";
are the same
There's no difference, because include
is a language construct that doesn't require parentheses, just like echo
.
See also: include - scroll up a little bit
include('file.php'):首先计算('file.php')的值,原因是值为file.php,然后将file.php包含到当前文件中; include'file.php':include file .php直接进入当前文件。如您所见,结果是一样的, 但第二种方式更有效。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.