Include will let the script keep running (with a warning) if the file is missing.
Require will crash if it's missing.
If you're using include for things which are 100% optional, then include will still work and require will explode.
If you include something that you think is optional, but some other piece of your script uses it, way down the line, then your script will explode there, and you'll probably have no idea why.
This is not a good way to write programs.
Otherwise, there isn't a difference between the two.
edit
In typical usage, it shouldn't matter whether you choose to use include
or require
, 95% of the time.
As such, you should stick to require
(or require_once
), to tell you when you're missing a file you need.
The bugs that come from including files inside of included files, inside of included files, when one include up top is missing, are really hard to track down.
Some people prefer include
, because they want to use that "feature".
Douglas Crockford is a JavaScript/Java/C++ guy, rather than PHP, but he suggests that features that look like bugs, or side effects which are indistinguishable from bugs, should be avoided for your sanity.
Mind you, if your entire project is completely class-based (or functional), and entirely modular, then you shouldn't have much use for include, aside from, say resetting values on a configuration-object at application initialization (including admin-override options or dev-debugging options) on an object that was already require
d.
As you might guess, there are other ways of doing this.
And these are just suggestions, but suggestions that come from people who are smarter than I am, with decades of experience in dozens of languages.
REF: Difference between "include" and "require" in php