Home >Backend Development >PHP Tutorial >Talk about the difference between require and include in PHP

Talk about the difference between require and include in PHP

青灯夜游
青灯夜游forward
2020-04-12 09:56:003721browse

This article will talk to you about the difference between require and include in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Talk about the difference between require and include in PHP

The difference between require and include in PHP

Same points:

 1 , are both used to include files

2. include_once and require_once both check whether the file is included

Differences:

1. When require includes a file, if there is an error in the file , the program will interrupt and display a fatal error.

2. When including a file, if there is an error in the file, the program will issue a warning and continue execution.

3. require is generally used at the beginning of the program

4. include is generally used in the program flow

## In short:

require will report an error. If you put

at the beginning, you will get a warning. If you put

in the middle, you will only need_once.

Recommended learning:

PHP video tutorial

The above is the detailed content of Talk about the difference between require and include in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete