Php - Include PATH (Search Path)

About

The include_path parameter specifies a list of directories where the:

  • require,
  • include,
  • fopen(),
  • file(),
  • readfile()
  • and file_get_contents()

functions look for files.

Syntax

The format is like the system's file PATH environment variable: a list of directories with the os path separator. ie

  • with a colon in Unix
include_path=".:/php/includes"
  • semicolon in Windows.
include_path=".;/php/includes"

Set

Programmatically

set_include_path(get_include_path().PATH_SEPARATOR."/path/to/my/file");
ini_set('include_path', '/usr/lib/pear');

Ini

The value of the include path is defined in php.ini

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
include_path=D:\xampp\php\pear
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path

Documentation / Reference


Powered by ComboStrap