error_reporting(0) 抛出 500 错误

发布于 2024-12-06 19:19:17 字数 193 浏览 1 评论 0原文

所以 - 我遇到了奇怪的情况。

语句 error_reporting(0); 一直给我一个服务器 500 错误。

然而,error_reporting(1); 工作得很好......

而且它杀了我,我的一些 URL 验证器有太多警告。这是怎么回事?知道如何解决这个问题吗?

So - strange situation I got here.

The statement error_reporting(0); has been giving me a server 500 error.

However, error_reporting(1); works just fine..

And its killing me, too many warnings for some of my URL validators. What's up with this? Any idea on how this can be fixed?

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

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

发布评论

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

评论(3

岁月染过的梦 2024-12-13 19:19:17

首先,如果我表现得很“自作聪明”,我很抱歉,但我必须告诉你,如果有警告,你应该考虑修复它们,而不是仅仅让它们保持沉默... :)

垃圾 PHP 代码会让不好的事情发生,你不会喜欢它。我知道 80% 的 PHP 代码都是垃圾,但如果它不是很大的话,真的要尝试修复该库。

但是,如果您只创建一个简单的 .php 文件,只有一行:

<?php
error_reporting(0);
?>

并测试它是否引发错误,我们可以尝试解决该问题。如果没有,则问题不是由 error_reporting 引起的,而只是由它触发的,并且其他地方出现了一些问题。 :)

First of all, I'm sorry if I behave "smartass", but I have to tell you that if there are warnings, you should consider to fix them instead of just reduce them to silence... :)

Junk PHP code let bad things happen, and you won't like it. I understand 80% of the PHP code around is junk, but really try to fix that library, if it's not huge.

We can however try to solve the problem if you just make a simple .php file, with only one line:

<?php
error_reporting(0);
?>

and test if it fires the error. If it doesn't, the problem is not caused by error_reporting, but just triggered by it, and there's some sick stuff going on elsewhere. :)

友欢 2024-12-13 19:19:17

尝试 error_reporting(E_ALL);和 ini_set("display_errors","开");并检查发生的错误。修好这些之后,应该就没有问题了。

祝你好运
谢伊。

PS 我几乎 100% 猜测您使用的是 Chrome,因为出于某种原因,chrome 有时会只显示自己的错误屏幕,而不是显示错误消息。因此,还可以尝试其他浏览器来检查错误。

try error_reporting(E_ALL); and ini_set("display_errors","On"); and check the errors that occur. After you fix those, there shouldn't be any problem.

Good luck
Shai.

P.S. i would be guessing for almost 100% that you use Chrome, because for some reason chrome would sometimes just show its own error screen instead of showing error messages. So also try another browser just to check the errors.

青柠芒果 2024-12-13 19:19:17

error_reporting()的值是用常量定义的,所以不要使用直接值来设置它。

如果您使用过这些常量,您会注意到它们都没有 0 作为值。

如果您想报告所有错误,则规则有一个例外:使用值 -1 :

error_reporting(-1);

来源:http://us.php.net/manual/en/function.error-reporting.php

并考虑修复所有警告! (甚至在可能的情况下进行通知)

注意:-1 值用于确保即使添加更多错误代码,它们也会全部包含在内。

error_reporting()'s value is defined with constants, so don't use direct value to set it.

If you had used the constants, you would have noticed that none of them have 0 as value.

If you want to report all errors, there is an exception to the rule : use the value -1 :

error_reporting(-1);

Source : http://us.php.net/manual/en/function.error-reporting.php

And consider fixing all warnings! (and even notices if possible)

Note : the -1 value is used to be sure that even if more error code are added, they are all included.

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