Skip to content

Instantly share code, notes, and snippets.

@patricknelson
Forked from scottsb/example.php
Created July 22, 2015 20:43
Show Gist options
  • Save patricknelson/94fd0c85b675177563d5 to your computer and use it in GitHub Desktop.
Save patricknelson/94fd0c85b675177563d5 to your computer and use it in GitHub Desktop.
Hack to handle multiple Exception types with a single block
<?php
class Foo extends Exception {}
class Bar extends Foo {} // Bar is a technically different but Foo-like exception.
class Baz extends Exception {}
try {
throw new Foo();
} catch (Foo $e) {
echo 'Case 1';
} catch (Baz $e) {
echo 'Case 2';
} catch (Exception $e) {
// Apparently do nothing :)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment