Reputation: 648
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';
it would probably look clearer to write include($_SERVER['DOCUMENT_ROOT'] . '/file.php');
Upvotes: 4
Views: 160
Reputation: 1
include('file.php') : calculate the value of ('file.php') firstly,of cause the value is file.php, and then include file.php into current file; include 'file.php' : include file.php into current file directly。 As you see, the result is the same, but the second way is more efficient。
Upvotes: 0
Reputation: 12836
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
Upvotes: 5