Home > Backend Development > PHP Tutorial > php异常处理类

php异常处理类

WBOY
Release: 2016-06-23 13:25:22
Original
858 people have browsed it

```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;}```

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template