include_once() statement refers to including and running the specified file during script execution.
This behavior is similar to the include() statement. The only difference is that if the code in the file is already included, it will not be included again. As the name of this statement implies, will only be included once.
include_once() should be used when the same file may be included more than once during script execution, and you want to ensure that it is only included once to avoid problems such as function redefinition and variable reassignment.
For more examples of using require_once() and include_once(), see the PEAR code in the latest php source program distribution package.
The return value is the same as include(). If the file is included, this function returns TRUE.
Note: include_once() is newly added in php 4.0.1pl2.
Note: Please note that the behavior of include_once() and require_once() may not be expected in case-insensitive operating systems (such as Windows).
Example include_once() is case-insensitive under Windows
<?php include_once("a.php"); // this will include a.php include_once("A.php"); // this will include a.php again on Windows! (php 4 only) ?>
Recommended tutorial; PHP video tutorial
The above is the detailed content of The meaning of include_once in php. For more information, please follow other related articles on the PHP Chinese website!