Hello comrades! I understand that the question is repeated, but it is still relevant!

The official PHP resource does not say in the require function description that it includes the specified files BEFORE the handler starts working, on the contrary, there is no significant difference between the require and include .

Earlier, I remember how it was said that require includes files BEFORE the handler starts working without paying attention to the position of this function and it will be executed according to the condition or not. It was used accordingly to include the necessary files, but was faster include did its job before the processor started working.

And include is good because it can dynamically connect files, for example in a loop, and in the absence of a file it will not stop the script, but only cause a warning.

Actually the question is: I am a serious enough PHP programmer, I need help on these functions, I need to speed up my scripts, tell me about these functions, how do they work in PHP5?

Here is one of the experiments:

<?php echo (function_exists('_tools_configurations')) ? 'ok': 'no'; require('./system/tools/_/_tools_configurations/_tools_configurations.php'); ?> 

    1 answer 1

    Practice shows that require works faster, but it collects the included files at the beginning of the script, and include connects along with this logic, it follows that if you have conditions for connecting files, use include, if there are no conditions, then require well and externally different error messages (if the file is not available) require more strict to this case.

    (c) some old site that used to crawl.

    • Well, the code that I posted, says that require will be executed after checking for the existence of a function that will be in the included file. In response, I received a "no". - Andrey Arshinov
    • one
      If explained on fingers and in coarse expressions, it turns out something like the following: include adds the code and then executes, while require first inserts the code (before the script starts), and executes it only when it comes to it. Conclusion: in your code at the time of execution of the echo function is not defined. - Indifferent
    • Thanks for the clarification! - Andrey Arshinov
    • 3
      Although it is rumored and confirmed by tests that with PHP5 there is only one difference between the include and require constructs - the first one gives only "Warning", and the second one also gives "Fatal error". So, require is a special solution for die() lovers in the function body. - Indifferent