php中异常处理方法总结:
当异常被触发时,通常会发生:
①.、异常类的层级关系:
代码如下 复制代码
class NotFoundException extends Exception{}
class InputException extends Exception{}
class DBException extends Exception{}
function exception_uncaught_handler(Exception $e) {
if ($e instanceof NotFoundException)
exit($e-getMessage());
elseif ($e instanceof DBException)
else
}
set_exception_handler('exception_uncaught_handler');
exception_uncaught_handler()函数处理:
$this-resConn = mysql_connect ($CONFIGS['db_host'], $CONFIGS['db_user'], $CONFIGS['db_pwd']);
if (false == is_resource($this-resConn))
throw new DBException('数据库连接失败.'.mysql_error($this-resConn));
if (0 != strcmp($curAlbum-interest_id, $it))
throw new NotFoundException('很抱歉,你所访问的相册不存在');
以上就是土嘎嘎小编为大家整理的在php中常见问题及解决方法相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!