Thursday, 22 August 2013

Unset an Exception that is thrown

Unset an Exception that is thrown

Is it possible to unset an Exception that got thrown, so that it is not
getting catched in PHP?
class TestException extends \Exception
{
public function __construct($msg = null, $errno = null) {
parent::_construct($msg, $errno);
unset($this);
}
}
function test() {
throw new TestException();
}
try {
// Throws Exception
test();
// Exception triggered but unset by itself,
// so it cannot be catched and does not result in an error
} catch (\Exception $e) {
print_r($e);
}
So by the code above, an Exception gets thrown but not catched and does
not result in a PHP error?

No comments:

Post a Comment