How can I make set_error_handler() call a method on an object?

前端 未结 3 480
你的背包
你的背包 2020-12-14 14:37

I think about using the set_error_handler() functionality in PHP to handle most of the PHP errors in one place (logging them to a file). From the documentation

3条回答
  •  遥遥无期
    2020-12-14 15:22

    In PHP 5.3 you could do it in a closure:

    $that = $this;
    set_error_handler( function() use ($that) { $that->customErrorHandler(); } );
    

提交回复
热议问题