note 114582 added to function.set-exception-handler

From: Date: Sat, 08 Mar 2014 23:42:15 +0000
Subject: note 114582 added to function.set-exception-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-198836@lists.php.net to get a copy of this message
By default the stack trace is pretty unreadable, so you might want to wrap it in <pre> tags. Here I also wrap it in a <div> and set the class 'alert alert-danger' which are CSS classes in the Bootstrap CSS framework to style them red. <?php function exception_handler($exception) { echo '<div class="alert alert-danger">'; echo '<b>Fatal error</b>: Uncaught exception \'' . get_class($exception) . '\' with message '; echo $exception->getMessage() . '<br>'; echo 'Stack trace:<pre>' . $exception->getTraceAsString() . '</pre>'; echo 'thrown in <b>' . $exception->getFile() . '</b> on line <b>' . $exception->getLine() . '</b><br>'; echo '</div>'; } set_exception_handler('exception_handler'); ---- Server IP: 212.63.222.76 Probable Submitter: 85.228.30.128 ---- Manual Page -- http://php.net/manual/en/function.set-exception-handler.php Edit -- https://master.php.net/note/edit/114582 Del: integrated -- https://master.php.net/note/delete/114582/integrated Del: useless -- https://master.php.net/note/delete/114582/useless Del: bad code -- https://master.php.net/note/delete/114582/bad+code Del: spam -- https://master.php.net/note/delete/114582/spam Del: non-english -- https://master.php.net/note/delete/114582/non-english Del: in docs -- https://master.php.net/note/delete/114582/in+docs Del: other reasons-- https://master.php.net/note/delete/114582 Reject -- https://master.php.net/note/reject/114582 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198836) next »