views:

1839

answers:

3

I've inherited some code on a system that I didn't setup, and I'm running into a problem tracking down where the PHP include path is being set.

I have a php.ini file with the following include_path

 include_path = ".:/usr/local/lib/php"

I have a PHP file in the webroot named test.php with the following phpinfo call

 <?php
      phpinfo();

When I take a look at the the phpinfo call, the local values for the include_path is being overridden

                 Local Value                                        Master Value
 include_path    .;C:\Program Files\Apache Software Foundation\     .:/usr/local/lib/php
                 Apache2.2\pdc_forecasting\classes

Additionally, the php.ini files indicates no additional .ini files are being loaded

Configuration File (php.ini) Path           /usr/local/lib
Loaded Configuration File                   /usr/local/lib/php.ini
Scan this dir for additional .ini files     (none)
additional .ini files parsed                (none)

So, my question is, what else in a standard PHP system (include some PEAR libraries) could be overriding the include_path between php.ini and actual php code being interpreted/executed.

+4  A: 

Outisde of the PHP ways

ini_set( 'include_path', 'new/path' );
// or
set_include_path( 'new/path' );

Which could be loaded in a PHP file via auto_prepend_file, an .htaccess file can do do it as well

phpvalue include_path new/path
Peter Bailey
Grumble grumble .htaccess. I combed through the http.conf looking for overrides and forgot about .htaccess.
Alan Storm
+2  A: 

An .htaccess file or Apache's configuration (httpd.conf) could also be responsible.

Check for anything that looks like the following:

php_value include_path something

More information about that behavior here:

PHP: How to change configuration settings


The other option would be the use of ini_set() or set_include_path() somewhere, but considering that your test.php only contains phpinfo() (and assuming that test.php is called directly), I doubt that is your problem.

Andrew Moore
+3  A: 

There are several reasons why you are getting there weird results.

  • include_path overridden somewhere in your php code. Check your code whether it contains set_include_path() call. With this function you can customise include path. If you want to retain current path just concatenate string . PATH_SEPARATOR . get_include_path()
  • include_path overridden in .htaccess file. Check if there are any php_value or php_flag directives adding dodgy paths
  • non-standard configuration file in php interpreter. It is very unlikely, however possible, that your php process has been started with custom php.ini file passed. Check your web server setup and/or php distribution to see what is the expected location of php.ini. Maybe you are looking at wrong one.
Michał Rudnicki
+1: Even if you are basically repeating everything that has been said already.
Andrew Moore