是否应该报告并修复PHP“通知"? [英] Should PHP 'Notices' be reported and fixed?

查看:63
本文介绍了是否应该报告并修复PHP“通知"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近切换到了一个报告PHP通知的新设置;我的代码在未修正这些通知的情况下运行良好,但是我想知道是否应该修复每个通知并报告它们,或者忽略它们并关闭通知报告.

I recently switched to a new setup that is reporting PHP Notices; my code has worked fine without these notices being fixed, but I am wondering if it makes sense to fix every one and leave them reported or just ignore them and turn notice reporting off.

对此有何不同意见?有与通知相关的最佳做法吗?

What are some different opinions on this? Are there any best practices associated with notices?

推荐答案

错误就是错误.必须先修复它们,然后才能使用代码.

Errors are errors. They have to be fixed before your code works.

警告是警告.他们警告您您正在做的事情可能不是一个好主意,即使目前它对您有用(或似乎有用).因此,它们也应该被修复.

Warnings are warnings. They warn you that what you're doing is probably a bad idea, even if it works (or seems to work) for you at the moment. So they too should probably be fixed.

通知是通知.他们应该被注意.由此得名.您的代码生成某些代码可能不是问题,但是您应该根据具体情况进行检查和判断.

Notices are notices. They should be noticed. Hence the name. It may not be a problem that your code generates some, but it's something you should examine and judge on a case-by-case basis.

当然,如果您没有收到通知,则更容易注意到通知.因此,尝试消除它们有很大的好处.它使您尚未注意到的内容变得更加引人注目.

And of course, it is much easier to notice notices if you don't get 400 of them. So there's a big benefit to trying to eliminate them. It makes the ones you haven't yet noticed become more noticeable.

这篇关于是否应该报告并修复PHP“通知"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆