note 100904 added to function.set-exception-handler

From: Date: Sun, 14 Nov 2010 02:50:30 +0000
Subject: note 100904 added to function.set-exception-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-174017@lists.php.net to get a copy of this message
<?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> ---- Server IP: 69.147.83.197 Probable Submitter: 27.18.120.6 ---- Manual Page -- http://www.php.net/manual/en/function.set-exception-handler.php Edit -- https://master.php.net/note/edit/100904 Del: integrated -- https://master.php.net/note/delete/100904/integrated Del: useless -- https://master.php.net/note/delete/100904/useless Del: bad code -- https://master.php.net/note/delete/100904/bad+code Del: spam -- https://master.php.net/note/delete/100904/spam Del: non-english -- https://master.php.net/note/delete/100904/non-english Del: in docs -- https://master.php.net/note/delete/100904/in+docs Del: other reasons-- https://master.php.net/note/delete/100904 Reject -- https://master.php.net/note/reject/100904 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174017) next »