PHP 有两个并行的系统来处理问题:传统的错误(warnings、notices、fatal errors)和异常(基于对象、可用 try/catch 捕获)。现代 PHP 在 Throwable 层次结构下统一了其中大部分,最佳实践倾向于使用异常。
传统错误级别
E_NOTICE → minor issues (e.g. using an undefined variable) — script continues
E_WARNING → non-fatal problems (e.g. include of a missing file) — continues
E_ERROR / Fatal → serious errors (e.g. calling an undefined function) — script HALTS
E_DEPRECATED → use of deprecated features
