Updated: 26 November 2024
Attempt to activate and display all errors, warnings, deprecations and notices
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', 'php-error.log')
// check the settings above
trigger_error('This is E_USER_DEPRECATED', E_USER_DEPRECATED);
trigger_error('This is E_USER_NOTICE', E_USER_NOTICE);
trigger_error('This is E_USER_WARNING', E_USER_WARNING);
trigger_error('This is E_USER_ERROR', E_USER_ERROR);
This script demonstrates how to temporarily adjust which PHP errors are reported, to avoid displaying a deprecation notice to users
// Activate every error, warning, deprecation & notice.
error_reporting(E_ALL);
// Get the current error reporting value.
$error_reporting = error_reporting();
// Reset the error reporting value but now excluding E_DEPRECATED.
error_reporting($error_reporting & ~E_DEPRECATED);
// With PHP 7.4, trigger an E_DEPRECATED.
get_magic_quotes_gpc();
// No deprecation message.
// Reset error reporting to original value.
error_reporting($error_reporting);
// Attempt to trigger an E_DEPRECATED.
get_magic_quotes_gpc();
// Deprecation message here.