note 100904 deleted from function.set-exception-handler by danbrown
| From: | danbrown@php.net | Date: | Sun, 14 Nov 2010 03:54:52 +0000 |
| Subject: | note 100904 deleted from function.set-exception-handler by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174018@lists.php.net to get a copy of this message | ||
Note Submitter: yibn2008 at gmail dot com
----
<?php
class Log
{
function __construct()
{
echo '<p>Log initialized...</p>';
}
function __destruct()
{
echo '<p>Log saved...</p>';
}
}
function exceptionHandle($ex)
{
echo "<b>Exception:</b> " , $ex->getMessage();
}
set_exception_handler('exceptionHandle');
function foo()
{
$log = new Log();
echo '<p>call foo</p>';
throw new Exception('Uncaught Exception Occurence');
echo 'the "echo" won\'t be executed';
}
foo();
?>
[output]
Log initialized...
call foo
Log saved...(Log::_destruct has been called)
Exception: Uncaught Exception Occurence
<p>In the PHP Manual, it says "Execution will stop after the exception_handler is called.
". As you see, the echo won't be executed, but the destruct function of Log did.</p>