Ben şu kod ile karıştı:
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->something();
} catch(AnotherException $e) {
print "caught AnotherException\n";
$a->somethingElse();
} catch(MyException $e) {
print "caught MyException\n";
}
} catch(Exception $e) {
print "caught Exception\n";
}
Ben çıkış için bu beklenir:
throwing AnotherException
caught AnotherException
throwing MyException
caught MyException
Ama bunun yerine bu çıkışları:
throwing AnotherException
caught AnotherException
throwing MyException
caught Exception
Bu catch (MyException $ e) "atlar" Herkes neden açıklayabilir misiniz?
Teşekkürler.