Jump to content

Another error reporting question


LLLLLLL

Recommended Posts

This is from php.net

 

display_errors string

This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.

 

Value "stderr" sends the errors to stderr instead of stdout. The value is available as of PHP 5.2.4. In earlier versions, this directive was of type boolean.

 

Note:

 

This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).

 

Note:

 

Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

 

If you wish to set error_reporting or display errors from a different setting other than the default value, you should place the ini_set at the top of your script(s)

Link to comment
Share on other sites

Thanks for your reply

 

Yes, I now see http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors. Useful page.

 

I don't really understand the part about fatal errors. Seems a little vague. Any more input there? Is it saying fatal errors won't be logged? That seems like exactly what you WOULD WANT to be logged. :)

 

Unless I'm misinterpreting it.

Link to comment
Share on other sites

I don't really understand the part about fatal errors. Seems a little vague. Any more input there? Is it saying fatal errors won't be logged? That seems like exactly what you WOULD WANT to be logged. :)

 

error_reporting is an error filter.  It simply allows you to setup which category of errors you want php to catch.  Most frequently, people will include E_NOTICE and E_STRICT messages during development and then exclude them on the production server. 

 

If during development you want to display the errors to screen, then you can use display_errors and display_startup_errors.  If you are trying to set these types of things up at runtime and your script does not even compile, you will not see any errors.  This is sometimes a surprise to people, when they get a blank page, and don't understand why they didn't get a stack trace, however, the error will be logged to the error log.  When you think about it, it makes complete sense that your runtime code never executes, because the program never made it past the parser to the state of being runable byte code.

 

Production applications often want to have custom behavior and application specific error handling.  This is where the issue with fatal runtime errors can come into play, however with 5.x there is a technique you can use that will even catch these fatal runtime errors.  For example you might have a logger that writes the error out to a log file in a particular format of your choice, or logs to a database, or emails you certain critical errors. 

 

I'm not going to go into the specifics of it, but you can find out more details if you're interested in these advance techniques.    The secret is to use register_shutdown_function

 

With that said, if you have a production server with display_errors off as it should be, and logging configured in the php.ini file, errors will go into the log file -- including runtime errors. 

 

 

Link to comment
Share on other sites

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.