php的异常捕捉
? ? ? 一直异或php的try catch 怎么使用
?
? ? ?看文档是说 需要new一个exception出来,才能catch到。
?
? ? ? 那如果需要捕捉到数组下限没找到 、或者方法传的参数不对 之类的 怎么办?
?
? ? ? 还好php提供了set_error_handler 这个函数,可以用户自己捕捉这些异常,比如:
getmessage(); } function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new errorexception($errstr, 0, $errno, $errfile, $errline); }
?
?
? ? ?这样就可以捕捉异常了