note 95433 deleted from language.exceptions by googleguy

From: Date: Sat, 12 Jan 2013 09:51:16 +0000
Subject: note 95433 deleted from language.exceptions by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192973@lists.php.net to get a copy of this message
Note Submitter: test30zxc at gmail dot com ---- If you are using exceptions, code which will store uncaught exceptions might be nice for you, for example, PDO throws an exception, but you thought that this is impossible, so you were not even thinking about using try{...}catch(...){...}, <?php function exception_handler($exception) { ob_start(); print_r($GLOBALS); print_r($exception); file_put_contents('exceptions.txt', ob_get_clean(). "\n",FILE_APPEND); } set_exception_handler('exception_handler'); ?> to save a uncatched exception simply write <?php throw new Exception('error'); ?> somewhere in code. If we have a lot of exceptions, file will get a huge size in few minutes, but saving this kind of information may save you from, for example, being sql-injected (attempt to try to inject-sql will be saved) PS PDO ofc. must be set to throw exceptions.

« previous php.notes (#192973) next »