Search notes:

PHP code snippets: including files

require_once()
get_include_path() returns the value of the include path which is a list of directories, separated by a colon (:), that are searched for files when files are included.

Suppress error messages

The following snippet uses the error control operator (@) to suppress error messages when include_once() does not find the requested file.
Additionally, the return value of include_once() is tested for success. If it returns false, the script is bailed out.
if (! @include_once("funcs.php")) {
   header('Content-Type: text/plain');
   print("Where is funcs.php?");
   exit(-1);
}

See also

Setting the include path in the .htaccess file.
PHP functions related to the filsystem

Index