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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758198689, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/php/snippets/including-files/index(57): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78