我試圖使用PHP 5.3.2拋出一個異常,這是給我下面的錯誤:PHP 5.3.2不拋出異常
解析錯誤:語法錯誤,意想不到的T_THROW
我試圖拋出異常的方式如下:
throw new Exception('Property ' . $name . ' doesn\'t exist in class Index', '');
編輯:我也試着
throw new Exception('Property ' . $name . ' doesn\'t exist in class Index');
它ð idn't改變我得到的錯誤。
完整的方法:
public function __get($name)
{
if(property_exists($this, $name)
throw new Exception('Property ' . $name . ' doesn\'t exist in class Index');
return $this->$name;
}
你可以在投擲前後顯示代碼嗎? – 2010-04-08 10:26:57