[英]What's the difference between include('file.php') and include 'file.php'
两者都include('file.php')
和include 'file.php'
工作,似乎是可以互换的。
有谁知道这两种语法之间是否有任何区别? 性能? 在特定版本中推出?
我知道如果你要写include $_SERVER['DOCUMENT_ROOT'] . '/file.php';
include $_SERVER['DOCUMENT_ROOT'] . '/file.php';
编写include($_SERVER['DOCUMENT_ROOT'] . '/file.php');
可能看起来更清晰include($_SERVER['DOCUMENT_ROOT'] . '/file.php');
没有区别。 这些是'语言结构'。 从语法上讲,这意味着它们可以使用或不使用大括号。 一个例子是echo
语句。
echo("hello");
并echo "hello";
是相同的
没有区别,因为include
是一种不需要括号的语言结构,就像echo
一样。
另请参阅: include - 向上滚动一点
include('file.php'):首先计算('file.php')的值,原因是值为file.php,然后将file.php包含到当前文件中; include'file.php':include file .php直接进入当前文件。如您所见,结果是一样的, 但第二种方式更有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.