内部関数が例外を投げるようにするset_error_handler()を利用する。 set_error_handler()のサンプル<?php function exceptionErrorHandler($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler('exceptionErrorHandler'); 例外発生を確認<?php error_reporting(E_ALL); try { $arr = array(); print $arr['a'] . "\n"; strpos(); } catch (Exception $e) { print $e->getMessage() . "\n"; print $e->getTraceAsString() . "\n"; } |
|