PHP include_once,require_once, and Include,require usage scenarios and differences.

Source: Internet
Author: User
A few days ago, the company has a Daniel to give us these rookie to speak PHP, he is mainly about some dry goods, and grammar what the matter, which has a thinking problem:

PHP include_once,require_once, and Include,require usage scenarios and differences?

A lot of people know include,require, or the difference between include_once and include, here I don't say, but very few people deeply understand why there is include_once, what do I need to include?

The situation was the same, I also think it is very interesting, because I have made this mistake before, I think include_once or require_once can avoid file repeated loading, that every time with it on the line, why also use include, so that I have a long time to write PHP code, It's all *_once. Until someone said I was not good at it, I argued with him for a while, and thought that this would avoid repeated loading .... And then to the performance of this piece ... Just dawned.

Existence is not only reasonable, I believe many people understand this truth, the less process procedures, the less time consuming, the more efficient, and a well-designed program, often efficient, we return to the point, include_once before each load of the file needs to determine whether the file is loaded, and include is not used, So in fact, from the performance of the include is more efficient, it must now be asked, it can not avoid repeated loading ah, indeed, but the program is written by people, and the reason people are called people, is that we exist thinking, back to the beginning of the sentence, a good design program we can avoid these things from the early design. Oh, what if it can't be avoided? With include_once ah ....

The above describes the PHP include_once,require_once, and Include,require use of the scene and the difference. , including the aspects of the content, want to be interested in PHP tutorial friends helpful.

  • 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.