LLLLLLL Posted June 22, 2011 Share Posted June 22, 2011 It seems that using error_reporting - http://php.net/manual/en/function.error-reporting.php - is not relevant if a site's php.ini file has display_errors = Off... is there a way to set that at runtime, too? Is ini_set the way to go? And if so, does it matter which function is called first (I'm guessing ini_set). Merci... Quote Link to comment https://forums.phpfreaks.com/topic/240142-another-error-reporting-question/ Share on other sites More sharing options...
fugix Posted June 22, 2011 Share Posted June 22, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/240142-another-error-reporting-question/#findComment-1233489 Share on other sites More sharing options...
LLLLLLL Posted June 22, 2011 Author Share Posted June 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240142-another-error-reporting-question/#findComment-1233503 Share on other sites More sharing options...
LLLLLLL Posted June 22, 2011 Author Share Posted June 22, 2011 Oh I see, "fatal" meaning "parser" errors? I can see why this isn't something that would work... Quote Link to comment https://forums.phpfreaks.com/topic/240142-another-error-reporting-question/#findComment-1233513 Share on other sites More sharing options...
gizmola Posted June 22, 2011 Share Posted June 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240142-another-error-reporting-question/#findComment-1233517 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.