欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php异常处理类

程序员文章站 2024-01-13 16:40:16
...
```getMessage().'in file:'.$this->getFile().'on line:'.$this->getLine(); }}function reg($reginfo = null){ // 依据不同错误抛出不同异常 if (empty($reginfo) || !isset($reginfo)) { throw new Exception('参数非法'); } if (empty($reginfo['email'])) { throw new emailException('邮件为空'); } if ($reginfo['pwd'] != $reginfo['repwd']) { throw new pwdException('两次密码不一致!'); }}// 接收不同异常,并针对性处理!try { reg(array('email' => '1078789950@qq.com', 'pwd' => '123', 'repwd' => '1231' ));} catch (Exception $e) { echo $e ->getMessage();} catch (emailException $ee) { echo $ee ->getMessage();} catch (pwdException $ep) { echo $ep;}```
相关标签: php异常处理类