php 异常

class customException extends Exception
{
    public function errorMessage()
    {
        //error message
        $errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
            .': <b>'.$this->getMessage().'</b> ';
        return $errorMsg;
    }
}

try
{
   throw  new customException("error le ");
}

catch (customException $e)
{
    //display custom message
    echo $e->errorMessage();
}
?>

  

posted @ 2017-11-10 17:42  brady-wang  阅读(270)  评论(0编辑  收藏  举报