What are the differences between php include and include_once?

烟雨青岚
Release: 2023-03-01 17:46:01
Original
4145 people have browsed it

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.

What are the differences between php include and include_once?

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";
?>
Copy after login

include_once

<?php
include_once "index.php";
// 其他代码
//
include_once "index.php";
?>
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!