PHP异常覆盖toString()
我自己的异常类有问题:PHP异常覆盖toString(),php,oop,tostring,Php,Oop,Tostring,我自己的异常类有问题:IOExeption。我希望它有另一个输出,然后是普通的异常类,但是尽管有下面的代码,它的输出仍然是一样的。 我做错了什么 class IOExeption extends Exception { public function __toString() { $string = '<h1 class="text-warning text-center">'; $string .= $this->getMes
IOExeption
。我希望它有另一个输出,然后是普通的异常类,但是尽管有下面的代码,它的输出仍然是一样的。我做错了什么
class IOExeption extends Exception
{
public function __toString()
{
$string = '<h1 class="text-warning text-center">';
$string .= $this->getMessage();
$string .= '</h1>';
return $string;
}
}
class IOExeption扩展异常
{
公共函数
{
$string='';
$string.=$this->getMessage();
$string.='';
返回$string;
}
}
事实上,异常应该没有任何输出
必须在异常处理程序中执行的任何输出。只有在开发服务器是您唯一的用户的情况下。否则,它必须以明文形式记录错误消息。您没有定义任何未捕获的异常处理程序吗?