PHP脚本执行异常预警
public bool Asf_Application::setErrorHandler(callable $error_handler)
First of all turn on asf.dispathcer.log.err = 1
Accept the function name, an array containing an object reference and a method name can also be supplied
设置成功返回 true, 否则会有异常信息提示
<?php // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { } $handle = new Asf\Application($configs); $handle->setErrorHandler('myErrorHandler'); $handle->run();
<?php // error handler function class Debug { public static function myErrorHandler($errno, $errstr, $errfile, $errline) { } } $handle = new Asf\Application($configs); $handle->setErrorHandler(array('Debug', 'myErrorHandler')); $handle->run();
<?php // error handler function class Debug { public function myErrorHandler($errno, $errstr, $errfile, $errline) { } } $handler = new Debug(); $handle = new Asf\Application($configs); $handle->setErrorHandler(array($handler, 'myErrorHandler')); $handle->run();
<?php class Bootstrap { public function __initAlarm() { $app = Asf\Application::getInstance(); $app->setErrorHandler(array($this, 'alarm')); } public function alarm($errno, $errstr, $errfile, $errline) { } } $handle = new Asf\Application($configs); $handle->bootstrap()->run();