Home  >  Article  >  Backend Development  >  Detailed explanation of the distinction between require, include, and use in PHP

Detailed explanation of the distinction between require, include, and use in PHP

亚连
亚连Original
2018-05-17 14:10:263248browse

The difference between require and include is that the error is reported when the file does not exist. The former stops the script and the latter continues execution. They all import a file, execute the imported file after the introduction, and continue to execute the current file after the execution is completed.
So the parameter value is the file address, use the left slash "/";

use is to use the namespace, so the parameter value is the namespace, use the right slash "\"

Namespaces and file paths do not necessarily correspond directly!

The above is the distinction between require, include, and use in PHP that I compiled for you. I hope it will be helpful to you in the future.

Related articles:

What are the differences between static variables and global variables in PHP?

PHP variable scope and global variables (graphic tutorial)

PHP closure function() use Detailed usage in ()


The above is the detailed content of Detailed explanation of the distinction between require, include, and use in PHP. 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