: This article mainly introduces the use of phprequire_once and the difference between phprequire_once and require. For more information about PHP tutorials, see. Differences:
Require_once only loads the same file once, and require loads the file multiple times.
I think there are still some doubts about the same little white as me. So we guess: if 456. php has introduced 123.php, the file test_require.php has introduced "456. php" and "123. php ". If the require method is used, 123. php will be introduced twice in test_require.php, and the require_once method 123. php will be introduced once. So let's do the experiment!
1. require method
123. php content is as follows:
456. php content is as follows:
The content of test_require.php is as follows:
Run test_require.php and the result is as follows:
II. require_once method
123. php content remains unchanged. 456. php and test_require.php change the require_once method. The content is as follows:
// 456.php
Run test_require.php and the result is as follows:III. mixed errors
If you use the require method in 456. php and the require_once method, require_once will become invalid. The code for the three files is as follows:
// 123.php
The running result is as follows:
Summary: As we guess, the require_once method does not load the same file multiple times. However, mixing with require will invalidate the require_once method.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above introduces the use of php require_once and the difference with require, including some content, hope to be helpful to friends who are interested in PHP tutorials.