note 95433 modified in language.exceptions by danbrown

From: Date: Mon, 04 Jan 2010 16:04:39 +0000
Subject: note 95433 modified in language.exceptions by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164616@lists.php.net to get a copy of this message
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. --was-- 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(...){...}, 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 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. http://php.net/manual/en/language.exceptions.php

« previous php.notes (#164616) next »