Skip to content

Instantly share code, notes, and snippets.

@kojiromike
Created July 23, 2015 18:15
Show Gist options
  • Save kojiromike/ca8577f3145a13d8ad00 to your computer and use it in GitHub Desktop.
Save kojiromike/ca8577f3145a13d8ad00 to your computer and use it in GitHub Desktop.
$ cat catchtest.php
<?php
interface FooFail {}
interface BarFail {}
class YesFail extends Exception implements FooFail, BarFail {}
class NoFail implements FooFail {}
try { throw new YesFail; }
catch (FooFail $e) { echo "Caught the foo\n"; }
try { throw new YesFail; }
catch (BarFail $e) { echo "Passed the bar\n"; }
try { throw new NoFail; }
catch (FooFail $e) { echo "Caught another foo\n"; }
$ docker run --rm -i php:5.3 php < catchtest.php
Caught the foo
Passed the bar
Fatal error: Exceptions must be valid objects derived from the Exception base class in - on line 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment