Require () vs require_once ()-Translated by Ma yongzhan

Source: Internet
Author: User

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.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.