douyiavxxh02727 2013-07-25 11:15
浏览 28

php错误代码和例外

I always read/hear people say "I use set_error_handler function to throw an excpetion whenever an error occurs so I'm only left with using exceptions as the error handling mechanism and don't bother using two mechanims to handle errors (i.e. php native errors and exceptions)" .

In my understantig this is not properly stated , php native error mechanism is primarly intended as an error-reporting mechanism and not as an error handling one,is this right ?

Php standard functions whenever triggering errors on failures should (and I think do) also use an error code based strategy , to let the programmer take appropriate actions, once again is this correct ?

As error-code based strategy I mean they could directly return error codes or give the programmer the chance to know about the problem by calling an appropriate functions or use others strategy like these.

So , shouldn't we say more properly that we use set_error_handler and php native error reporting mechanism as a trick to be only left working with exceptions and so we don't bother check for errors values?

PS: I'm fairly new to PHP , don't be too rude if I'm saying something totally crazy :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记