Home > Article > Backend Development > What are the differences between php include and include_once?
The difference between include and include_once is: include will load the specified file and execute the program inside, and repeat the inclusion multiple times; the include_once function will load the specified file and execute the program inside. If the If the file has already been included, it will not be included again.
The difference between include and include_once
include will load the specified file and execute the program inside; repeat The reference is included multiple times.
include_once function will load the specified file and execute the program inside; this behavior is similar to the include statement, the only difference is that if the file has already been included, it will not be included again.
include
<?php include "index.php"; // 其他代码 // include "index.php"; ?>
include_once
<?php include_once "index.php"; // 其他代码 // include_once "index.php"; ?>
Recommended tutorial: "php tutorial"
The above is the detailed content of What are the differences between php include and include_once?. For more information, please follow other related articles on the PHP Chinese website!