PHP 的 include_path - 将其设置为空字符串不起作用

发布于 2024-11-03 00:08:01 字数 271 浏览 2 评论 0原文

我有 Apache HTTP Server v2.2 和 FastCGI 通信中的 PHP。

我尝试将 php.ini 中的 include_path 变量编辑为空字符串,但它不起作用, 路径仍然是:.:/usr/local/lib/php(如 phpinfo() 所示)。
如果我将包含路径设置为冒号 (:),则包含路径最终会更改。

如何将其设置为空字符串?

谢谢。

I have Apache HTTP Server v2.2 with PHP in FastCGI communication.

I tried to edit the include_path variable in php.ini to an empty string but it didn't work,
the path remains: .:/usr/local/lib/php (as seen by phpinfo()).
If I set the include path to a colon (:), then the include path finally changes.

How can I set it to an empty string?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往日 2024-11-10 00:08:01

该值必须是除空字符串之外的其他值。如果您不希望 PHP 从任何地方包含任何内容,您可以将其设置为某个不存在的路径(并让它在尝试包含内容时找不到该路径)。这不是一个理想的解决方案,但它会起作用。

不过,我有一种感觉,你的做法是错误的。 include_path 非常有用,除非您打算在任何地方对应用程序的路径进行硬编码(在我看来,这本身就是一个坏主意)。如果您将其设置为 .,那么应该足以删除不应该出现在其中的路径,同时保持其对于 include 内容的实用性。

The value has to be something besides an empty string. If you don't want PHP to include anything from anywhere, you can set it to some nonexistent path (and let it fail to find the path when it tries to include stuff). It's not an ideal solution, but it'll work.

I have a feeling you're going about this wrong, though. include_path is extremely useful, unless you intend to hard-code your app's path everywhere (which is a bad idea in itself, IMO). If you set it to just ., that should be enough to get rid of paths that shouldn't be in there, while keeping it practical to include stuff.

百变从容 2024-11-10 00:08:01

现在问题背后有了更多背景。这更多的是一个系统管理员问题,但这是响应:

每个虚拟主机您可以配置特定的 php.ini 设置:

对于 apache:https: //serverfault.com/questions/34078/how-do-i-set-up-per-site-php-ini-files-on-a-lamp-server-using-namevirtualhosts

http://php.net/manual/en/configuration.changes.php

现在,如果您没有将此应用于虚拟主机,并且是针对每个用户的,那么我更确定这在用户 public_html 配置下是可能的。

Now that there is more context behind the question. This is more of a sysadmin question, but here's the response:

Per virtual host you can configure specific php.ini settings:

For apache: https://serverfault.com/questions/34078/how-do-i-set-up-per-site-php-ini-files-on-a-lamp-server-using-namevirtualhosts

http://php.net/manual/en/configuration.changes.php

Now, if you aren't applying this to virtual hosts, and it's per user, I'm more then certain this is possible under the user public_html configurations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文