php.ini include_path

試著忘記壹切 提交于 2020-01-10 14:32:33

问题


I've searched all over the place and can't seem to find an answer for this. I'm trying to set an include path in the php.ini file of my local wamp server. I currently don't understand one of two things:

  1. What to put in the quotes of the include path setting itself.
    For example, if I wanted to add C:\wamp\www as an include path, would it be
    include_path = ".;C:\wamp\www\"?
  2. Where to put the include path line. Can I put it anywhere, or do I have to put it in a specific place?

Some common errors I've read about in my research that I've checked.

  • I'm editing the php.ini file located at C:\wamp\bin\php\php5.3.8
  • I've restarted the server after I've made my changes and have checked if it had updated using the phpinfo() function.

UPDATE
This is currently what I have, but it still doesn't work.

; Windows: "\path1;\path2"
include_path = ".;C:\php\pear;C:\wamp\www"

回答1:


This all depends on what you are trying to accomplish. Personally, I don't edit the php.ini file directly for setting include_paths, rather I use the following construct, in code:

// This will append whichever path you would like to the current include path
// And I believe that PHP is smart enough to convert / with \ if on a windoze box
// If not you can replace / with DIRECTORY_SEPARATOR
set_include_path(get_include_path() . PATH_SEPARATOR . 'my/custom/path');

-- Edit --

Chances are there may be multiple copies of php.ini on your system, and that you are not editing the one that is being used by PHP.




回答2:


The php.ini file will have include_path already in it, but commented out, that is where you should put it, by uncommenting it. It also has examples for windows. It will look like this, just remove the semicolon preceding "include_path"

; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"



回答3:


Hit this link when I was trying to debug why the include_path in my php.ini file was not taking effect. I am talking about my ubuntu setup with a bitnami api. The solution was to restart the php-fpm using ./ctlscript properly. Was restarting only apache but had to restart php-fpm as well.

Hopefully helps somebody trying it in ubuntu with a bitnami lampstack.




回答4:


If you discover this thread and you're using a current version of WAMPServer you might run into the issue I had where you edit the php.ini referenced in the phpinfo() report, but it doesn't change the includes path. Doing a search of the WAMP directory showed 2 DLL's (both named php5ts.dll in the php and apache dirs) where the include path is specified. Use the Bitnami WAMP environment instead (https://bitnami.com/stack/wamp/installer). GO PATS!



来源:https://stackoverflow.com/questions/9345109/php-ini-include-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!