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');
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With