difference:
Require_once will only load the same file once, require will load multiple times.
I believe that the same as my small white or some doubts it. So we assume: if 456.php introduced 123.php, now file test_require.php introduced "456.php" and "123.php". If the Require method is used, then in test_require.php, 123.php is introduced 2 times, and 123.php is introduced once using the Require_once method. Then let's do the experiment!
First, Require method
The contents of 123.php are as follows:
The 456.php content is as follows:
Require ("123.php"); echo "456\n";
The contents of test_require.php are as follows:
Run test_require.php to get the result as follows:
Second, require_once method
123.php content does not change. 456.php and test_require.php Change the Require_once method. The contents are as follows:
//456.php!--? phprequire_once "123.php"; echo "456\n";//test_require.php
Run test_require.php with the following result:
third, mixed error
If you use the Require method in 456.php, the Require_ Once method, then the require_once will fail. Three file codes are as follows:
//123.php!--? Phpecho "123\n";//456.php
The result of the operation is as follows:
Summary: As we suspect, the Require_once method does not load the same file multiple times. However, mixing with require will invalidate the Require_once method.
Copyright notice: This article is a blogger original article, not allowed to be reproduced without the permission of Bo master.
Above introduces the use of PHP require_once and the differences with require, Include aspects of the content, you want to be interested in PHP tutorial friends helpful.