Difference between "include" and "require" in php

Dan Hanly picture Dan Hanly · Sep 3, 2010 · Viewed 121.3k times · Source

Is there any difference between them? Is using them a matter of preference? Does using one over the other produce any advantages? Which is better for security?

Answer

efritz picture efritz · Sep 3, 2010

require will throw a PHP Fatal Error if the file cannot be loaded. (Execution stops)

include produces a Warning if the file cannot be loaded. (Execution continues)

Here is a nice illustration of include and require difference:

enter image description here

From: Difference require vs. include php (by Robert; Nov 2012)