7

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.

Siamak Motlagh
  • 5,028
  • 7
  • 41
  • 65
Richard Knop
  • 81,041
  • 149
  • 392
  • 552

4 Answers4

17

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()

Asaph
  • 159,146
  • 25
  • 197
  • 199
9

Separate them with colons (:).

set_include_path("/some/dir:/other/dir:.");

More info on php.net.

Annika Backstrom
  • 13,937
  • 6
  • 46
  • 52
7

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));
CommandZ
  • 3,333
  • 1
  • 23
  • 28
1

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");