A few days ago, a senior person in the company came to teach us novices about PHP. He mainly talked about some practical information, and it had nothing to do with grammar. Among them was a question to think about: C Include_ONCE, Require_ONCE, and Include, Require's usage scenarios and differences?
Many people know the difference between include, require, or include_once and include. I won’t go into it here, but few people understand deeply why include_once is included. What else does include need to do? The situation was also like this at that time. I also found it very interesting because I had made this mistake before. I thought include_once or require_once could avoid repeated loading of files. Then it would be enough to use it every time. Why use include? The PHP codes I wrote for a long time all used *_once. Until someone said that I couldn't write well like this, I argued with him for a while, thinking that this could avoid repeated loading... Then when it came to performance... I suddenly realized it. ================================================================================================================================================================================================================================================================================================= It is necessary to determine whether the file has been loaded before the file is loaded, but include does not, so in terms of performance, include is more efficient. Now some people must ask, then it cannot avoid repeated loading. Indeed, but the program is written by people, and people The reason why we are called humans is because we have thinking. Going back to the sentence at the beginning of the paragraph, with a well-designed program we can avoid these things from the beginning. Haha, what if it cannot be avoided? Use include_once. . . .The above introduces the usage scenarios and differences of include_once, require_once, and include and require in PHP. , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.