试用了一把php的try catch极其失望,除了名字相同,其他的。。。比如:
try{
if(class_exists($act['action'])){
$obj=new $act['action']($act,$this->_pDate);
}else{
throw new Exception("");
}
}catch (Exception $e){
die("System error for wrong action mapping for this application");
}
居然需要自行throw。。。这就完全失去了try catch真正的意图了。。。
原因很清楚php是一种不允许错的语言,他的语句是“没有错误”的概念,所以try catch也就成了摆设。。。
try{
if(class_exists($act['action'])){
$obj=new $act['action']($act,$this->_pDate);
}else{
throw new Exception("");
}
}catch (Exception $e){
die("System error for wrong action mapping for this application");
}
居然需要自行throw。。。这就完全失去了try catch真正的意图了。。。
原因很清楚php是一种不允许错的语言,他的语句是“没有错误”的概念,所以try catch也就成了摆设。。。
本文探讨了PHP中try-catch异常处理机制的实际使用情况,作者对于需要显式抛出异常感到失望,认为这偏离了try-catch的设计初衷。
8486

被折叠的 条评论
为什么被折叠?



