【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-user_defined_exception.php,希望本篇文章对您学习有所帮助。
<?php
class myException extends Exception
{
function __toString()
{
return '<table border><tr><td><strong>Exception '. $this->getCode()
. '</strong>: '. $this->getMessage().'<br />'.' in '
. $this->getFile(). ' on line '. $this->getLine()
. '</td></tr></table><br />';
}
}
try
{
throw new myException('A terrible error has occurred', 42);
}
catch (myException $m)
{
echo $m;
}
?>