Home  >  Article  >  Backend Development  >  What is the usage of php require

What is the usage of php require

藏色散人
藏色散人Original
2020-07-28 09:18:262337browse

php The require statement means including and running the specified file, and require will generate a fatal error "E_COMPILE_ERROR" and stop the script. Its statement usage is "require( dirname(__FILE__) . '/wp-load.php' ) ;".

What is the usage of php require

Recommended: "PHP Tutorial"

How to use php require

How to use the require() statement in php

The require() statement includes and runs the specified file.

require() statement includes and runs the specified file.

require() and include() are identical in every respect except how they handle failure.

require generates a fatal error (E_COMPILE_ERROR) and stops the script

include generates only a warning (E_WARNING), and the script continues

include() generates a warning while require( ) results in a fatal error.

In other words, if you want to stop processing the page when a file is missing, don't hesitate to

use require(). This is not the case with include() and the script will continue to run. Also make sure the appropriate include_path is set.

require( dirname(__FILE__) . '/wp-load.php' );

The above is the detailed content of What is the usage of php require. 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