require_once will only load the same file once, while require will load it multiple times.
I believe that novices like me still have some doubts. So we guessed: If 456.php introduced 123.php, now the file test_require.php introduces "456.php" and "123.php". If the require method is used, then in test_require.php, 123.php will be introduced twice, and using therequire_oncemethod 123.php will be introduced once. So let’s do the experiment!
The content of 123.php is as follows:
Copy after login
The content of 456.php is as follows:
##
require("123.php"); echo "456\n";
Copy after login
123.php content remains unchanged. 456.php and test_require.php change the require_once method. The content is as follows:
##
//456.phpCopy after login
//123.phpCopy after login
The above is the detailed content of php: The difference between require_once and require. For more information, please follow other related articles on the PHP Chinese website!