Friday, 10 August 2018

PHP Question: Include And Require Files

Question

What's the difference between include() and require()?

Answer

The answer is how they both deal with failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
This is an important distinction as if your script uses bit of code in an external file, and it isn't there, then you can either chose the make the script stop, or continue and fail gracefully.

0 comments:

Post a Comment