Home  >  Article  >  Backend Development  >  What is the use of include_once in php

What is the use of include_once in php

王林
王林Original
2020-06-30 10:31:444008browse

The function of the include_once statement in php is to include and run the specified file during script execution. The include_once statement is similar to the include statement. The only difference is that the include_once statement does not include the file repeatedly, but only once.

What is the use of include_once in php

Function: The

include_once statement includes and runs the specified file during script execution.

It 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_once can 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.

Example:

<?php
include_once "a.php"; // 这将包含 a.php文件
?>

If you want to know more related issues, please visit php Chinese website.

The above is the detailed content of What is the use of include_once in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn