title: Confused by this PHP Exception try..catch nesting
body: <p>I'm confused by the following code:</p>
  
  <pre><code>class MyException extends Exception {}
  class AnotherException extends MyException {}
  
  class Foo {
    public function something() {
      print "throwing AnotherException\n";
      throw new AnotherException();
    }
    public function somethingElse() {
      print "throwing MyException\n";
      throw new MyException();
    }
  }
  
  $a = new Foo();
  
  try {
    try {
      $a-&gt;something();    
  
    } catch(AnotherException $e) {
      print "caught AnotherException\n";
      $a-&gt;somethingElse();    
    } catch(MyException $e) {
      print "caught MyException\n";
    }
  } catch(Exception $e) {
    print "caught Exception\n";
  }
  </code></pre>
  
  <p>I would expect this to output:</p>
  
  <pre><code>throwing AnotherException
  caught AnotherException
  throwing MyException
  caught MyException
  </code></pre>
  
  <p>But instead it outputs:</p>
  
  <pre><code>throwing AnotherException
  caught AnotherException
  throwing MyException
  caught Exception
  </code></pre>
  
  <p>Could anyone explain why it "skips over" catch(MyException $e) ?</p>
  
  <p>Thanks.</p>