Set numerous include paths?
Solution 1
Separate them with colons (:).
set_include_path("/some/dir:/other/dir:.");
More info on php.net.
Solution 2
To do this in a cross platform manner use the PATH_SEPARATOR constant:
set_include_path('/my/path' . PATH_SEPARATOR . '/my/other/path');
FYI: You can also set the include path in php.ini
or in your apache vhost configuration.
For your further reference: PHP documentation on set_include_path()
Solution 3
Setting Numerous Include Paths
Here is a way, in a platform independent manner, to set numerous include paths from an array of values:
$paths = array(
'path/one/',
'path/two/',
'path/three/'
);
set_include_path(get_include_path() . PATH_SEPARATOR . implode(PATH_SEPARATOR, $paths));
Solution 4
This works for me :-)
ini_set("include_path", ".;C:\wamp\bin\php\php5.3.13\pear;.;C:\wamp\bin\php\php5.3.13\Zend\library");
Richard Knop
I'm a software engineer mostly working on backend from 2011. I have used various languages but has been mostly been writing Go code since 2014. In addition, I have been involved in lot of infra work and have experience with various public cloud platforms, Kubernetes, Terraform etc. For databases I have used lot of Postgres and MySQL but also Redis and other key value or document databases. Check some of my open source projects: https://github.com/RichardKnop/machinery https://github.com/RichardKnop/go-oauth2-server https://github.com/RichardKnop
Updated on June 15, 2022Comments
-
Richard Knop almost 2 years
I know how to set an include path:
set_include_path('/path');
But how can I set multiple include paths? For example: in two different directories.
-
Jakub Míšek almost 7 yearsNote this won't work on Windows. Use platform independent PATH_SEPARATOR instread of colons.