java程序员学php -16 exception处理

写法与java风格一致

      throw new Exception('exception', 33);  //比java多了一个error_code

      try{
        $d -> doSecond();
      }catch(Exception $e){
        echo $e.getMessage();
      }

不同点:

1.php里没有 throws Exception

2.php里的exception没有 checked exception 与 unchecked之分

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.