-1
如何處理方法拋出的異常?這是必要的,該方法沒有拋出異常的方法「檢查」如何處理PHP 5.4中的方法拋出的異常?
<?php
class AllAccidents
{
public static function check() {
try {
$x = 1;
if($x)
throw new Exception("Value must be more than 1");
}catch (Exception $e){
echo "hello>>".$e->getMessage();
}
}
}
class Test
{
public function go(){
try{
AllAccidents::check();
} catch (Exception $e){
}
}
}
$obj = new Test();
$obj->go();
?>