PHP difference between notice and warning

后端 未结 6 1514
不知归路
不知归路 2020-12-08 10:09

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,

6条回答
  •  心在旅途
    2020-12-08 10:31

    According to PHP Manual:

    • WARNING - Run-time warnings (non-fatal errors). Execution of the script is not halted.
    • NOTICE - Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.

    Personally I think, that notices indicate some code parts, which potentially can lead to some problems, but which were introduced intentionally. In such cases programmer is considered to "know what he is doing" and to know about some particular PHP features (type casts, default initialization values etc).

提交回复
热议问题