<?php
class MyException extends Exception { //继承异常类;
function getInfo() {
return '自定义错误信息';
}
}
try {
throw new MyException('error'); //抛出异常;
} catch(Exception $e) {
echo $e->getInfo();
}