include() vs require() vs *_once()

By | 14 March, 2011

Just to settle this once and for all:

include(‘file.php’); // will include file.php and emite a WARNING if the file is not found

require(‘file.php’); // will include file.php and emit a FATAL ERROR if the file is not found

require_once(‘file.php’); // PHP will check if the file has already been included, and if so, not include (require) it again.

include_once(‘file.php’); // same as require_once, but will evaluate the file before (yes, its include, with warning and checks to see if file exists).

So there you have it, kids. Just so you(*i*) never forget.