我正在尝试使用 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');
它并没有改变我得到的错误。
完整的方法:
public function __get($name)
{
if(property_exists($this, $name)
throw new Exception('Property ' . $name . ' doesn\'t exist in class Index');
return $this->$name;
}