PHP中错误控制@运算符

来源:互联网 发布:微信小程序 源码下载 编辑:程序博客网 时间:2024/05/17 03:13

PHP支持一个错误控制运算符:at符号(@)。添加在PHP中表达式之前时,任何错误消息都会被忽略

如果你有一个自定义的错误处理函数set_error_handler()那它仍会被调用,但这个自定义错误处理程序可以(也应该调用error_reporting(),当出发的错误之前有@符号,它返回0

如果track_errors功能启用时,任何错误消息将被保存在变量php_errormsg中。这个变量将每个错误被覆盖所以如果你想使用它要尽早检查


原文:

PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.

If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) callerror_reporting() which will return 0 when the call that triggered the error was preceded by an @.

If the track_errors feature is enabled, any error message generated by the expression will be saved in the variable$php_errormsg. This variable will be overwritten on each error, so check early if you want to use it.




0 0
原创粉丝点击