php错误接管

<?php
set_error_handler("error_function",E_ALL);
try{
    echo 'ok';
    echo $_POST['id'];
}catch(Exception $e){
    echo $e->getMessage();
}

function error_function($errno, $errstr, $errfile, $errline) {
    echo "<b>Custom error:</b> [$errno] $errstr<br>";
    echo " Error on line $errline in $errfile<br>";
}

 

posted on 2017-10-25 10:15  长风剑客  阅读(126)  评论(0编辑  收藏  举报

导航