Similarities and differences between include (), include_once (), require (), and require_once ()-unique196:
First, include (), include_once (), require (), and require_once () are used to include and run specified files, and the contained files are exactly the same in structure during execution.
Example: include ("file. php ");
Include_once ("file. php ");
Require ("file. php ");
Require_once ("file. php ");
Differences:
1. different use methods
Include () and include_once () are generally placed in the PHP process control program.
Require () and require_once () are usually placed at the beginning of the PHP program. before the PHP program is executed, it will first read the file specified by require.
2. errors are reported in different ways during execution.
When the include () or include_once () file does not exist or an error occurs, it continues to run and displays a warning error. a returned value is returned.
When require () or require_once () does not exist or an error occurs, the execution is stopped and an error is reported. a fatal error is displayed and no return value is returned.
The differences between include (), require (), include_once (), and require_once:
Include () and require (): When the same file is contained multiple times, the same file content is repeatedly imported.
Include_once (), require_once (): checks whether the target file has been imported before. If yes, the same file will not be imported repeatedly.
Now I have summarized so much and learned together!