According to the PHP manual, require and
include "are identical in every way except how they handle
failure." However, further reading of the manual suggests another very
subtle difference that impacts performance.
When you use the require keyword, the named file is read
in, parsed, and compiled when the file using the require
keyword is compiled. When a file containing the include keyword
is compiled, the named file is not read in, parsed, and
compiled initially. Only when that line of code is executed is the file
read, parsed and compiled.
Only use the require keyword if you know you
will always need that named file in the current script. If you
might use its functions, use include instead. PHP
opens up all files that are required, but only opens included files as
needed.
Additionally, you should also consider using require_once
and include_once in place of require and
include respectively. In practice, it is more likely that you
actually want the functionality provided by the require_once
and include_once functions, even though it is much more
common to use the require and include keywords
respectively.
Refer to the following PHP manual pages for more information: include, include_once,
require, require_once.