note 73759 added to function.error-reporting

From: Date: Fri, 09 Mar 2007 04:36:12 +0000
Subject: note 73759 added to function.error-reporting
Groups: php.notes 
Request: Send a blank email to php-notes+get-124258@lists.php.net to get a copy of this message
A simple and effective way to catch Fatal errors. From here you can go forward with your own ideas and elaborate a detailed error report. The principle is simple and ready to test on your system Fatal errors are not currently catched and you should have display errors off in production sites, but may be you need to test the system so you want a fast an easy way to see fatal errors in your currently running site, without the users seeing those Fatal errors as recomended. You must have this function function catchFatalErrors($p_OnOff='On'){ ini_set('display_errors','On'); $phperror='><div id="phperror" style="display:none">'; ini_set('error_prepend_string',$phperror); $phperror='</div>><form name="catcher" action="/sos.php" method="post" ><input type="hidden" name="fatal" value=""></form> <script> document.catcher.fatal.value = document.getElementById("phperror").innerHTML; document.catcher.submit();</script>'; ini_set('error_append_string',$phperror); } Now activate your fatal error catcher catchFatalErrors(); Just to test write this inexistent function Bitagenda(); That's all. As you can see there will be a form posted with action="/sos.php", of course you can name this page at your liking, in this case is at the site's root. Have ready your page sos.php, and elaborate on that. Of course change the mail address to yours,and display a message to the user at your liking. <?php if (isset($_POST['fatal'])){ error_log($_POST['fatal'],1,'bitagenda@gmail.com'); } ?> "System Out of Service. Thanks for waiting." The other fact about this handler is that even if you do not redirect the Fatal Error, prepending ><div style="display:none"> and appending </div> Then writting yor personal message " Sorry, fatal bug." Will hide the fatal error message from the user, but will be visible in the browsers soure code view. What happens if you redirect the page before displaying the error? I don´t know, have not tested, but at least you could do it to alert you that a fatal error exists and possibly the fatal error is not displayed (leading to security and at the same time catching the fatal error). Then you could activate this error handler with post-redirection to see what's going on. ;o) Bitagenda ---- Server IP: 216.194.113.175 Probable Submitter: 216.62.70.35 ---- Manual Page -- http://www.php.net/manual/en/function.error-reporting.php Edit -- https://master.php.net/note/edit/73759 Del: integrated -- https://master.php.net/note/delete/73759/integrated Del: useless -- https://master.php.net/note/delete/73759/useless Del: bad code -- https://master.php.net/note/delete/73759/bad+code Del: spam -- https://master.php.net/note/delete/73759/spam Del: non-english -- https://master.php.net/note/delete/73759/non-english Del: in docs -- https://master.php.net/note/delete/73759/in+docs Del: other reasons-- https://master.php.net/note/delete/73759 Reject -- https://master.php.net/note/reject/73759 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124258) next »