apache 什么可以更改 php.ini 和 PHP 文件之间的 include_path
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1156414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What can change the include_path between php.ini and a PHP file
提问by Alan Storm
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
我有一个包含以下 include_path 的 php.ini 文件
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 。
回答by Peter Bailey
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 .htaccessfile can do do it as well
可以通过 加载到 PHP 文件中auto_prepend_file,.htaccess文件也可以这样做
phpvalue include_path new/path
回答by Micha? Rudnicki
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
.htaccessfile. Check if there are anyphp_valueorphp_flagdirectives 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.inifile 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. 也许你看错了。
回答by Andrew Moore
An .htaccessfile 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:
有关该行为的更多信息,请访问:
The other option would be the use of ini_set()or set_include_path()somewhere, but considering that your test.phponly contains phpinfo()(and assuming that test.phpis called directly), I doubt that is your problem.
另一种选择是使用ini_set()或set_include_path()某处,但考虑到您test.php只包含phpinfo()(并假设test.php直接调用),我怀疑这是您的问题。

