Home > Backend Development > PHP Tutorial > The difference between include, include_once, require, require_once

The difference between include, include_once, require, require_once

WBOY
Release: 2016-07-29 09:12:02
Original
1073 people have browsed it

1. include, require includes a file at the location where it is called.

2. include_once, require_once function has the same function as include, but it will first verify whether the file has been included. If it is already included, include_once will no longer be executed. Others are the same as include.

3. The main difference between require and include is that a. When require makes an error, the script will stop running, while when include makes an error, the script will continue to execute. b. Regardless of the location of require, the formulation file will be included in the script where require appears. For example, even if require is placed in an if statement that evaluates to false, the specified file will still be included.

4. Use require_once to solve the problem of file being overwritten. require_once function ensures that the file is included only once. After encountering require_once, subsequent attempts to include the same file will be ignored.

The above introduces the differences between include, include_once, require, and require_once, including the require content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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