Home > Backend Development > PHP Problem > What is the usage of php require

What is the usage of php require

藏色散人
Release: 2023-03-03 11:48:02
Original
2404 people have browsed it

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' );
Copy after login

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!

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