Skip to content

Instantly share code, notes, and snippets.

@bramus
Created October 10, 2014 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bramus/47dad1ed98102f767aaa to your computer and use it in GitHub Desktop.
Save bramus/47dad1ed98102f767aaa to your computer and use it in GitHub Desktop.
PHP Exception Typehinting
<?php
class DummyException extends Exception {
// ...
}
class Dummy {
public function __construct() {
throw new Exception('...');
}
}
class Dummy2 {
public function __construct() {
throw new DummyException('...');
}
}
try {
// $d = new Dummy();
$d = new Dummy2();
} catch(DummyException $e) {
echo 'DummyException caught' . PHP_EOL;
} catch(Exception $e) {
echo 'Exception caught' . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment