- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- PHP/例外/内部関数が例外を投げるようにする へ行く。
- 1 (2011-04-08 (金) 01:57:58)
内部関数が例外を投げるようにする
set_error_handler()を利用する。
<?php
error_reporting(E_ALL);
function exceptionErrorHandler($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler('exceptionErrorHandler');
try {
$arr = array();
print $arr['a'] . "\n";
strpos();
} catch (Exception $e) {
print $e->getMessage() . "\n";
print $e->getTraceAsString() . "\n";
}