九州编程
PHP有异常和错误(这个也算PHP设计上的一个缺陷,不过PHP7已经改变了大多数错误的报告方式)异常处理和其他语言类似(JAVA、JavaScript、c#...)PHP错误处理PHPreportserrorsinresponsetoanumberofinternalerrorconditions.Thesemaybeusedtosignalanumberofdifferentconditions,andcanbedisplayedand/orloggedasrequired.EveryerrorthatPHPgeneratesincludesatype.Alistofthesetypesisavailable,alongwithashortdescriptionoftheirbehaviourandhowtheycanbecaused.PHP7改变了大多数错误的报告方式。不同于传统(PHP5)的错误报告机制,现在大多数错误被作为Error异常抛出。这种Error异常可以像Exception异常一样被第一个匹配的try/catch块所捕获。如果没有匹配的catch块,则调用异常处理函数(事先通过set_exception_handler()注册)进行处理。如果尚未注册异常处理函数,则按照传统方式处理:被报告为一个致命错误(FatalError)。https://www.php.net/manual/zh...控制异常上报规则在php.ini修改error_reporting=xxx在运行时调用error_reporting(xxx)PS:针对你的情况可以使用isset或??运算符