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.
我在一个我没有设置的系统上继承了一些代码,我遇到了一个跟踪PHP包含路径设置的问题。
I have a php.ini file with the following include_path
我有一个php.ini文件,其中包含以下include_path
include_path = ".:/usr/local/lib/php"
I have a PHP file in the webroot named test.php with the following phpinfo call
我在webroot中有一个名为test.php的PHP文件,其中包含以下phpinfo调用
<?php
phpinfo();
When I take a look at the the phpinfo call, the local values for the include_path is being overridden
当我查看phpinfo调用时,将覆盖include_path的本地值
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
此外,php.ini文件表明没有加载其他.ini文件
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.
所以,我的问题是,标准PHP系统中的其他内容(包括一些PEAR库)可能会覆盖php.ini和正在解释/执行的实际php代码之间的include_path。
3 个解决方案
#1
Outisde of the PHP ways
超越PHP的方式
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
哪个可以通过auto_prepend_file加载到PHP文件中,.htaccess文件也可以这样做
phpvalue include_path new/path
#2
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 anyphp_value
orphp_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 ofphp.ini
. Maybe you are looking at wrong one.
include_path在php代码中的某处覆盖。检查代码是否包含set_include_path()调用。使用此功能,您可以自定义包含路径。如果要保留当前路径,只需连接字符串即可。 PATH_SEPARATOR。 get_include_path()
include.path在.htaccess文件中重写。检查是否有任何php_value或php_flag指令添加狡猾的路径
php解释器中的非标准配置文件。不太可能,你的php进程已经通过传递自定义php.ini文件启动了。检查您的Web服务器设置和/或php发行版,看看php.ini的预期位置是什么。也许你看错了。
#3
An .htaccess
file or Apache's configuration (httpd.conf
) could also be responsible.
.htaccess文件或Apache的配置(httpd.conf)也可以负责。
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
PHP:如何更改配置设置
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.
另一种选择是在某处使用ini_set()或set_include_path(),但考虑到你的test.php只包含phpinfo()(假设直接调用test.php),我怀疑这是你的问题。
#1
Outisde of the PHP ways
超越PHP的方式
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
哪个可以通过auto_prepend_file加载到PHP文件中,.htaccess文件也可以这样做
phpvalue include_path new/path
#2
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 anyphp_value
orphp_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 ofphp.ini
. Maybe you are looking at wrong one.
include_path在php代码中的某处覆盖。检查代码是否包含set_include_path()调用。使用此功能,您可以自定义包含路径。如果要保留当前路径,只需连接字符串即可。 PATH_SEPARATOR。 get_include_path()
include.path在.htaccess文件中重写。检查是否有任何php_value或php_flag指令添加狡猾的路径
php解释器中的非标准配置文件。不太可能,你的php进程已经通过传递自定义php.ini文件启动了。检查您的Web服务器设置和/或php发行版,看看php.ini的预期位置是什么。也许你看错了。
#3
An .htaccess
file or Apache's configuration (httpd.conf
) could also be responsible.
.htaccess文件或Apache的配置(httpd.conf)也可以负责。
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
PHP:如何更改配置设置
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.
另一种选择是在某处使用ini_set()或set_include_path(),但考虑到你的test.php只包含phpinfo()(假设直接调用test.php),我怀疑这是你的问题。