andybeak
3/21/2017 - 12:21 PM

PHP Exception inheritance

PHP Exception inheritance

<?php

class MyException extends Exception {}

try {

  throw new MyException();

} catch (Exception $e) {

    echo "Parent exception";

} catch (MyException $e) {

    echo "Child exception";

}

?>