特定文件夹的错误报告

发布于 2024-07-25 08:36:19 字数 110 浏览 2 评论 0 原文

有没有办法为特定目录设置 error_reporting(E_ALL); 而不是将其包含在每个文件中?

我想为我的 beta.mysite.com 启用错误报告

is there a way to set error_reporting(E_ALL); for a specific directory rather than including it in each file?

I'd like to turn on error reporting for my beta.mysite.com

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

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

发布评论

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

评论(4

↘人皮目录ツ 2024-08-01 08:36:19

您可以在 Apache 中使用 .htaccess 文件。 只需添加这一行:

php_value error_reporting 6143

或者对于旧的 PHP 版本:

php_value error_reporting 2047

请注意,您不能使用

手册

注意:PHP 之外的 PHP 常量

在 PHP 之外使用 PHP 常量,
就像在 httpd.conf 中一样,不会有
有用的意义,所以在这种情况下
需要整数值。 自从
错误级别将随着时间的推移而增加,
最大值(对于 E_ALL)将
可能会改变。 所以代替E_ALL
考虑使用更大的值来覆盖
从现在开始一直到所有位字段
未来,一个数值,例如
2147483647。

You can use a .htaccess file in Apache. Just add this line:

php_value error_reporting 6143

Or for old PHP versions:

php_value error_reporting 2047

Note that you can't use the contants (like E_ALL)

From the manual:

Note: PHP Constants outside of PHP

Using PHP Constants outside of PHP,
like in httpd.conf, will have no
useful meaning so in such cases the
integer values are required. And since
error levels will be added over time,
the maximum value (for E_ALL) will
likely change. So in place of E_ALL
consider using a larger value to cover
all bit fields from now and well into
the future, a numeric value like
2147483647.

肤浅与狂妄 2024-08-01 08:36:19

使用 .htaccess 文件来设置选项。

<IfModule mod_php5.c>
  display_errors 1
</IfModule>

现在,这自然只有在您使用apache 作为一个模块。

如果您想在使用 CGI 时添加配置选项,您的选项将受到限制。

一些想法:

  • 在每个脚本中都包含一些内容。
  • 更奇特的是:使用重写规则,该规则指向执行通常的 set_ini 样式参数的目录中的已知脚本,然后通过检查路径包含预期的脚本。 我不喜欢重写规则,但我知道这是可以做到的。

Use an .htaccess file to set the option.

<IfModule mod_php5.c>
  display_errors 1
</IfModule>

Now, naturally this only works if you are using apache as a module.

If you want to add the configuration option when using CGI, your options going to be limited.

A couple of ideas:

  • Including something in every script.
  • More exotic: Use a rewrite rule which pointed to a known script in the directory which did the usual set_ini style argument, and then included the intended script by checking the path. I'm bad with rewrite rules, but I know this could be done.
此岸叶落 2024-08-01 08:36:19

简单说明一下:仅当 PHP 作为 Apache 模块安装时,将 PHP 指令放入 .htaccess 中才有效。 将 PHP 作为 CGI 安装后,您得到的只是 500 内部服务器错误

Just a quick note: putting PHP instructions into .htaccess works only if PHP is installed as an Apache module. With PHP installed as CGI all you get is a 500 Internal server error.

潦草背影 2024-08-01 08:36:19

对于 CGI 模式,您必须使用 php.ini 来完成此操作

for CGI mode you must use php.ini to accomplish that

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