Copyright statement: original works can be reproduced. During reprinting, be sure to mark them as hyperlinks.ArticleOriginal publication, author information, and this statement. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan
Require () vs require_once ()
I just found that require_once () is slower than require (). Previously, all my projects used require_once...
> It is best to directly use include or require,
> * _ Once () is very slow in calling under an opcode cache.
> # _ Once () needs to check whether the file has been called by the system.
Note:
5.2.x optimizes require_once () and include_once (), so you don't have to worry about this problem.
Abstract The article is as follows:
Before PHP 5.2, the require_once () and include_once () operations are based on fopen (), regardless of whether a file has been cached or compiled, after opening the file, check whether the file has been cached. The reason for this is that before PHP 5.1, it was not a perfect solution to the problems of realpath () relative paths and symbolic connections. If you cannot uniquely and correctly determine the true path representation of a path, you cannot use the uniqueness of the path to solve a problem. Fopen does not have this concern. This problem of realpath () has been completely solved in PHP 5.1, but the results have been delayed until now before it can be applied to require_once () and include_once. The advantage of solving this problem is to avoid the I/O operation of fopen. In many high-load scenarios, databases, networks, or disk I/O, rather than CPUs, are usually the bottlenecks.