php--自定义异常处理器
发布日期:2021-05-06 21:09:08 浏览次数:22 分类:原创文章

本文共 418 字,大约阅读时间需要 1 分钟。

<?phpclass cusException extends Exception{    public function errorMessage()    {        $errorMsg = "异常发生在行:".$this->getLine()." in ".$this->getFile()."--不是一个有效的邮箱地址:".$this->getMessage();        return $errorMsg;    }}$email = "jack@mamacom";try{    if(filter_var($email,FILTER_VALIDATE_EMAIL) == false)  //验证邮箱    {        throw new cusException($email);    }}catch (cusException $ce){    echo $ce->errorMessage();}

 

上一篇:php--表单演示文本框
下一篇:php--异常处理try-catch捕获异常

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月13日 02时29分02秒