php.ini include_path

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9345109/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:37:07  来源:igfitidea点击:

php.ini include_path

phpinclude-path

提问by Kevin Pei

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:

我到处搜索,似乎无法找到答案。我正在尝试在本地 wamp 服务器的 php.ini 文件中设置包含路径。我目前不明白两件事之一:

  1. What to put in the quotes of the include path setting itself.
    For example, if I wanted to add C:\wamp\wwwas an include path, would it be
    include_path = ".;C:\wamp\www\"?
  2. Where to put the include pathline. Can I put it anywhere, or do I have to put it in a specific place?
  1. 在包含路径设置本身的引号中放什么。
    例如,如果我想添加C:\wamp\www为包含路径,是
    include_path = ".;C:\wamp\www\"吗?
  2. 包含路径行放在哪里。我可以把它放在任何地方,还是我必须把它放在一个特定的地方?

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.
  • 我正在编辑位于的 php.ini 文件 C:\wamp\bin\php\php5.3.8
  • 我在进行更改后重新启动了服务器,并检查了它是否已使用该phpinfo()功能进行了更新。

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

更新
这是目前我所拥有的,但它仍然不起作用。

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

回答by Mike Purcell

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:

这一切都取决于您要实现的目标。就个人而言,我不会直接编辑 php.ini 文件来设置 include_paths,而是在代码中使用以下构造:

// 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.

您的系统上可能有多个 php.ini 副本,并且您没有编辑 PHP 正在使用的那个副本。

回答by thenetimp

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"

php.ini 文件中已经包含 include_path ,但通过取消注释将其注释掉,这就是您应该放置它的位置。它也有 windows 的例子。它看起来像这样,只需删除“include_path”前面的分号

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

回答by ram

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.

当我试图调试为什么我的 php.ini 文件中的 include_path 没有生效时,点击这个链接。我正在谈论我的 ubuntu 设置和一个 bitnami api。解决方案是正确使用 ./ctlscript 重新启动 php-fpm。仅重新启动 apache,但也必须重新启动 php-fpm。

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

希望可以帮助有人在 ubuntu 中使用 bitnami 灯组尝试它。

回答by Ginja Ninja

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!

如果您发现此线程并且您使用的是当前版本的 WAMPServer,您可能会遇到我在编辑 phpinfo() 报告中引用的 php.ini 时遇到的问题,但它不会更改包含路径。搜索 WAMP 目录显示 2 个 DLL(在 php 和 apache 目录中均名为 php5ts.dll),其中指定了包含路径。改用 Bitnami WAMP 环境 ( https://bitnami.com/stack/wamp/installer)。去拍!