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.
Comments
arent they identical... apart from include() on fail produces a warning and the rest of the script can continue, whereas require() on fail will produce an error and the script will cease
The difference between them is that require() will cause the script to fail if the file cannot be included, while include() will not.
include() produces a warning in the event the file is not available.
require() produces a fatal error in the event the file is not available.
I didn't know about this. I could have looked in the docs, but since you brought it up, I wanted to find out from you.