error_reporting(0) 抛出 500 错误
所以 - 我遇到了奇怪的情况。
语句 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,如果我表现得很“自作聪明”,我很抱歉,但我必须告诉你,如果有警告,你应该考虑修复它们,而不是仅仅让它们保持沉默... :)
垃圾 PHP 代码会让不好的事情发生,你不会喜欢它。我知道 80% 的 PHP 代码都是垃圾,但如果它不是很大的话,真的要尝试修复该库。
但是,如果您只创建一个简单的 .php 文件,只有一行:
并测试它是否引发错误,我们可以尝试解决该问题。如果没有,则问题不是由
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:
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. :)尝试 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.
error_reporting()
的值是用常量定义的,所以不要使用直接值来设置它。如果您使用过这些常量,您会注意到它们都没有 0 作为值。
如果您想报告所有错误,则规则有一个例外:使用值 -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 :
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.