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();
}
?>

  

原文地址:https://www.cnblogs.com/brady-wang/p/7815752.html