【发布时间】:2011-04-21 03:42:09
【问题描述】:
是否可以从 __toString 中删除跟踪元素。
我想要的是这样的。
class DBException extends PDOException
{
public function __toString()
{
return get_class($this) . " '{$this->getMessage()}' in {$this->getFile()}({$this->getLine()})\n";
}
}
我已经尝试过上述方法,但似乎不起作用。有什么想法吗?
如果我使用下面的 try catch 块作为示例,我仍然可以获得跟踪数据。
try {
// Do something here
}catch(DBException $e) {
echo $e;
}
我原以为回显 $e 会触发我的 DBException 类中的 __toString 方法。
【问题讨论】:
-
请解释一下似乎不起作用