【发布时间】:2011-06-30 21:15:15
【问题描述】:
如果方法不存在 Method() 或 getMethod(),我正在尝试显示自定义错误消息:
public function __call($name, $args = array()){
$getter = "get{$name}";
try {
echo call_user_func_array(array(&$this, $getter), $args);
} catch (Exception $e) {
trigger_error($e->getFile.' on line '.$e->getLine.': Method '.$name.' is not defined.', E_USER_ERROR)
}
}
但它不起作用。我在浏览器中收到“连接被远程服务器关闭”消息:|
【问题讨论】:
-
是的,我知道,但我想使用这个 try catch 东西,因为它告诉我错误所在的行/文件
-
Alex 你知道如何抛出异常吗?
-
我为什么要这样做?什么是期望?
标签: php exception error-handling