I always use something like this in a configuration file:
// Toggle this to change the setting
define('DEBUG', true);
// You want all errors to be triggered
error_reporting(E_ALL);
if(DEBUG == true)
{
// You're developing, so you want all errors to be shown
display_errors(true);
// Logging is usually overkill during development
log_errors(false);
}
else
{
// You don't want to display errors on a production environment
display_errors(false);
// You definitely want to log any occurring
log_errors(true);
}
This allows easy toggling between debug settings. You can improve this further by checking on which server the code is running (development, test, acceptance, and production) and change your settings accordingly.
Note that no errors will be logged if error_reporting is set to 0, as cleverly remarked by Korri.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…