The difference between include
and require
is the way an error is handled. require
produces a E_COMPILE_ERROR
error, which terminates execution of script . include
only produces a warning that can be "stuffy" with @
.
include_once
is guaranteed that the file will not be included again if it has already been added before.
require_once
is analogous to include_once
require_once
is a statement therefore the syntax with parentheses may confuse a little. At first glance it may seem like a function. That's why I do not advise you to use it, although it does not have harmful consequences.
Difference of quotes
As for using single quotation marks (or apostrophe) or double quotation marks (double commas) in this case will taste. Particularly I prefer, whenever possible, to use double quotes and only use simple quotes when necessary. An example is when there are double quotation marks within string text.
In the specific case you can not have either of the double quotes in the filename or path so the pair will always be suitable. Even double quotes allow the use of variable interpolation. Eg: include "$nome.php";
(although in this case the syntax is unnecessary).
Just remembering that using the double quotes requires a double parser to handle the interpolation. It is therefore more efficient to use single quotes. But nothing that is very significant.
I would not advise using the first example shown. There is no advantage and it causes the impression that myfile.php
is a symbol of the program.
As all forms are accepted by PHP all can be used, no matter the form chosen, the most important is to have standardization. Choose a shape and stick with it.
I do not know of any extra disadvantages beyond legibility in any way.
I do not know if it's obvious but you can also use require_once $minhavar;
if the variable obviously contains a complete valid for a PHP file.
What can make the difference is the location where one of these statements is being used. It respects the scope. But that's another matter.
I've placed it on GitHub for future reference .