来自命令行的 运行 php 脚本不同 include_path?
Different include_path when run php script from command line?
我在 require_once('directory/file.php')
、"failed opening required..." 上遇到致命错误。我知道所需的文件在我的 php includes 文件夹中 c:\PHP_Includes\directory\file.php
。当我查看 phpinfo() 时,我看到了正确的 include_path: ".;c:\PHP_Includes"
但在命令行错误中显示 include_path='.;C:\php\pear;C\Projects\project1\classes'
知道为什么 运行 命令行脚本的路径似乎不同吗?
问题与 WampServer 有大量 php ini 文件有关。确保将它们全部与正确的设置保持同步,以避免在使用一个而不是另一个时出现问题。
来自 http://forum.wampserver.com/read.php?2,72804 的非常有用的信息:
There is actually 3 php.ini files in WampServer
This is how they are used...
C:\Wamp\bin\php\phpX.X.X\php.ini This is only used by wampserver and php cli exe. WampServer's menu is built using php and this is the
config file that is used. It is also used if you are using php through
the command line interface. You generally never need to edit this
file.
C:\Wamp\bin\php\phpX.X.X\phpforapache.ini This is a copy of the php.ini file used for your websites. When this version of php is being
used this file is copied into the apache bin folder. If you change
version of php the apache\bin\php.ini is then emptied and the
phpforapache.ini of the new version of php is loaded into whichever
version of apache is loaded.
C:\Wamp\bin\apache\apacheX.X.X\bin\php.ini This is the actual php.ini that is loaded for your websites. provided that this is the
version of apache being used. This is copied from the relevant active
php folder( phpforapache.ini).
This may seem a little confusing but it is nessecary for WampServer's
ability to change version of apache and php easily. The best thing to
remember is..
If you want to manually edit your php.ini file for websites then
always use the wampserver menu to open it . >> left click the
WampServer icon > php > php.ini
If you want to manually edit your php.ini file for command line then
open php.ini in the current php folder.
我在 require_once('directory/file.php')
、"failed opening required..." 上遇到致命错误。我知道所需的文件在我的 php includes 文件夹中 c:\PHP_Includes\directory\file.php
。当我查看 phpinfo() 时,我看到了正确的 include_path: ".;c:\PHP_Includes"
但在命令行错误中显示 include_path='.;C:\php\pear;C\Projects\project1\classes'
知道为什么 运行 命令行脚本的路径似乎不同吗?
问题与 WampServer 有大量 php ini 文件有关。确保将它们全部与正确的设置保持同步,以避免在使用一个而不是另一个时出现问题。
来自 http://forum.wampserver.com/read.php?2,72804 的非常有用的信息:
There is actually 3 php.ini files in WampServer
This is how they are used...
C:\Wamp\bin\php\phpX.X.X\php.ini This is only used by wampserver and php cli exe. WampServer's menu is built using php and this is the config file that is used. It is also used if you are using php through the command line interface. You generally never need to edit this file.
C:\Wamp\bin\php\phpX.X.X\phpforapache.ini This is a copy of the php.ini file used for your websites. When this version of php is being used this file is copied into the apache bin folder. If you change version of php the apache\bin\php.ini is then emptied and the phpforapache.ini of the new version of php is loaded into whichever version of apache is loaded.
C:\Wamp\bin\apache\apacheX.X.X\bin\php.ini This is the actual php.ini that is loaded for your websites. provided that this is the version of apache being used. This is copied from the relevant active php folder( phpforapache.ini).
This may seem a little confusing but it is nessecary for WampServer's ability to change version of apache and php easily. The best thing to remember is..
If you want to manually edit your php.ini file for websites then always use the wampserver menu to open it . >> left click the WampServer icon > php > php.ini
If you want to manually edit your php.ini file for command line then open php.ini in the current php folder.