是否可以從__toString中刪除跟蹤元素。從PDOException __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;
}
我會想到echo $ e會觸發我的DBException類中的__toString方法。
請解釋*似乎不工作* – Gordon 2010-10-05 08:01:49