Home >Backend Development >PHP Tutorial >Usage and differences of require.include.require_once.include_once_PHP Tutorial
The usage and difference of require.include.require_once.include_once
Four ways to reference files: require. include. require_once. include_once.
The usage method of require is as require("MyRequireFile.php");. This function is usually placed at the front of the PHP program. Before the PHP program is executed, it will first read in the file specified by require and make it a part of the PHP program web page. Commonly used functions can also be introduced into web pages in this way.
The use method of include is include("MyIncludeFile.php");. This function is generally placed in the processing part of flow control. The PHP program webpage only reads the include file when it reads it. In this way, the process of program execution can be simplified.
The methods of require_once and include_once are the same as the methods of require and include. The only difference is that require_once and include_once will only include the file once and will not include it repeatedly.