Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/152501-restrict-number-of-errors-shown/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.