Chris Koerner <nobelx(a)gmail.com> writes:
Please don't use W3Schools for PHP information. Information on any PHP
keyword can be found by typing "http://php.net/KEYWORD" into your
browser's URL bar.
For example,
http://php.net/require takes you to a page that clearly
explains the difference between the two:
require is identical to include except upon failure it will also
produce a fatal E_COMPILE_ERROR level error. In other words, it will
halt the script whereas include only emits a warning (E_WARNING)
which allows the script to continue.
In the general scheme of things, is one a better
practice over the other?
On my sites, I like to know as soon as possible if there is a problem.
require() will give an error if a file doesn't exist instead of trying
to continue. If a site continues to operate with missing files, you'll
probably end up with errors that are harder to diagnose than they need
to be.
Mark.
--
Mark A. Hershberger
NicheWork LLC
717-271-1084