reasonman Posted April 4, 2009 Share Posted April 4, 2009 Hi. I setup an error handler and exception class, and when I get an error, it outputs all the errors down the line. The problem is it doesn't just show, say an error about an undefined variable, it shows that one, then hits the next error, say a database exception caused by the bad var, and displays that again so i'll get two messages that say "ERROR!" with everything else I have output. I haven't been able to find anything, but is there a way to restrict the number of errors that are shown? Or am I going to have to have a global variable or something to keeps track of it? Quote Link to comment https://forums.phpfreaks.com/topic/152501-restrict-number-of-errors-shown/ Share on other sites More sharing options...
Maq Posted April 4, 2009 Share Posted April 4, 2009 I'm not sure how to restrict the quantity of a specific error but you should take a look in the manual: error_reporting(). Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/152501-restrict-number-of-errors-shown/#findComment-800999 Share on other sites More sharing options...
reasonman Posted April 4, 2009 Author Share Posted April 4, 2009 Thanks, I read through, comments as well but it made no mention of anything like what I want. I'm wondering how other sites do it, just output a single error. Quote Link to comment https://forums.phpfreaks.com/topic/152501-restrict-number-of-errors-shown/#findComment-801009 Share on other sites More sharing options...
PFMaBiSmAd Posted April 4, 2009 Share Posted April 4, 2009 Your code should contain logic to validate inputs and avoid doing things like executing queries using non-existent data. Well written applications don't normally generate fatal, warning, or notice errors, only for unexpected conditions, such as a legitimate visitor entering valid but unexpected data or a hacker entering things trying to break or break into your script. All real life application code should be written with error checking (validate inputs and check if something worked or not), error reporting/logging (output meaningful user messages and log the important details so you have a record of problems that need to be fixed), and error recovery (what does your code do when an error occurs at each step, blindly continue executing, generating more errors, or take an appropriate action depending on the severity of the detected error.) error_reporting should be set to E_ALL and display_errors should be set to OFF on a live server. Error logging should be ON so that you have a record of things like a hacker trying to trigger errors in an attempt to find out information about your server, account, and scripts. Edit: other sites that only output the first error have error recovery logic in the program so that after the first error that will prevent the code from performing as expected is detected, the code ends in a controlled manner instead of blindly continuing execution using non-existent data. Quote Link to comment https://forums.phpfreaks.com/topic/152501-restrict-number-of-errors-shown/#findComment-801015 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.