PHP: How to set the value of the include_path: set_include_path

Various functions in PHP have options to search for files in a fixed set of directories often known as include_path. When you include another PHP file in another PHP program, the interpreter searches for the file in the directories mentioned in the include_path and reports an error if not found. The include_path value can be overwritten by a program. But it is better to extend the current value and add more directories. The following program does that. It gets the current value and extends the new value. Note the use of the PATH_SEPARATOR, which is a variable to signify the separator between two directories.

print get_include_path()."n";
$path = "../../config";
print get_include_path()."n";

The output of the program is as follows

$php value.php

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s