* 内部関数が例外を投げるようにする [#s8f7ae50]

set_error_handler()を利用する。

*** set_error_handler()のサンプル [#h8f9e6ee]
 <?php
 error_reporting(E_ALL);
 function exceptionErrorHandler($errno, $errstr, $errfile, $errline) {
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
 }
 set_error_handler('exceptionErrorHandler');

*** 例外発生を確認 [#p1dbff56]
 <?php
 error_reporting(E_ALL);
 try {
    $arr = array();
    print $arr['a'] . "\n";
    strpos();
 } catch (Exception $e) {
    print $e->getMessage() . "\n";
    print $e->getTraceAsString() . "\n";
 }

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS