Skip to content

Instantly share code, notes, and snippets.

@t-cyrill
Last active August 29, 2015 14:02
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 t-cyrill/86a43dc63f4271924f8d to your computer and use it in GitHub Desktop.
Save t-cyrill/86a43dc63f4271924f8d to your computer and use it in GitHub Desktop.
<?php
$e = null;
try {
throw new RuntimeException('foo');
} catch (Exception $e) {
// Catch and set $e if Exception thrown.
} finally {
// Do something
if (isset($e)) {
throw new $e;
}
}
<?php
$result = true;
try {
throw new RuntimeException('foo');
} catch (Exception $e) {
// Catch and set $e if Exception thrown.
$result = false;
} finally {
// Do something
var_dump($e);
if (isset($e)) {
throw new $e;
}
}
<?php
$result = false;
try {
if ($f) {
throw new RuntimeException('foo');
}
$result = true;
} finally {
// Do something
var_dump($result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment