I wa开发者_StackOverflownt to keep errors out of my PHP output stream. I only want output of things I explicitly echo.
Looking at my php.ini, is "display_errors" the only configuration I need to change?
Instead of modifying php.ini
, you can call this at a very early part of your code:
error_reporting(0);
Note that this means fatal errors will die silently as well, so it makes it a little difficult to debug at first.
I only recommend that if we're talking about a production machine. display_errors
will hide them from the user, but make sure you have log_errors
and error_log
set in the php.ini so you'll see them on your regular log analysis (you do, right?).
For a development machine, I recommend keeping display_errors
on and error_reporting(E_ALL | E_STRICT)
so you'll see if anything is fishy.
You can modify that INI directive and change the flag to 0
(False) or disable error_reporting on a page by page basis
error_reporting(0)
Typically Production environments should be on display_errors = 0
Though not all of us have both Development and Production environments
You can also change the "verbosity" of the error messages by passing different values to error_reporting
function (Or by changing the INI value for it in php.ini) More information on that can be found here: PHP: Runetime Configuration - error_reporting
精彩评论