How and When to use set_include_Path?

I don’t really understand when and how to use set_include_path and what is the combination with get_include_path function?

usually you don’t have to worry about the include path, as you should always work with absolute paths.

Absolute path, then how to setup it correctly?

I could never get set_include_path to work; I suppose it could have been disabled by the hosts at the time.

Now I tend to set the include path in the php.ini file

So before that, how you are config the paths through which methods?

I have a good interest in these type of questions related to PHP software development. It is used to set the include_path configuration option for the duration of the script. The description is

string set_include_path
    ( string $new_include_path

The Example is:


// Or using ini_set()
ini_set('include_path', '/usr/lib/pear');

and get_include_path() - Gets the current include_path configuration option

I hope this is clear to you now…

Cheers :slight_smile:

include paths are normally set by the OS (cf. env ). and there is really no need to play with include paths in PHP as you have access to the current directory path through __DIR__ and the host’s web root through $_SERVER['DOCUMENT_ROOT'].

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.