通知和警告之间的 PHP 区别

2021-12-26 00:00:00 error-handling php

在编写代码错误时,可能会出现警告和通知.我知道错误背后的想法.我想有一个警告是为了通知您可能导致错误的事情,但通知不一样吗?我想通知不是做正确事情的消息;)

When writing code errors, warnings and notices can occur. I know the idea behind errors. I suppose a warning is there to inform you about something that can cause an error, but isn't a notice exaclty the same? I suppose a notice is not a message of something doing right ;).

这让我有点困惑.谁能说出这两者之间的区别以及应如何处理这些消息.

It's just a bit confusing to me. Can anybody tell the difference between those two and the way these messages should be treated.

推荐答案

通知是一条咨询消息,意思是你可能不应该做你正在做的事情,但无论如何我会让你做"

A notice is an advisory message meaning "You probably shouldn't be doing what you're doing, but I'll let you do it anyway"

警告是一条消息,表示您做错了一些事情,很可能在未来导致错误,所以请修复它."

A warning is a message saying "You are doing something wrong and it is very likely to cause errors in the future, so please fix it."

通知和警告都不会停止您的脚本的执行,尽管我鼓励您认真对待它们并努力在您的应用中没有任何通知.

Both notices and warnings will not halt execution of your script, although I would encourage you to take them seriously and strive to have not even one notice in your apps.

相关文章