Disable PHP Error Display on the Front End
Suppresses PHP error, warning, and notice output on the public site so internal details are never leaked to visitors.
PHPby SnipCraft
php
<?php
/**
* Hides PHP errors and warnings from the front-end HTML output.
* Errors are still written to the server error log when WP_DEBUG_LOG is true.
* This does not affect wp-admin or CLI output.
*/
if ( ! function_exists( 'scseed_hide_php_errors_frontend' ) ) {
function scseed_hide_php_errors_frontend() {
if ( is_admin() || ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) ) {
return;
}
ini_set( 'display_errors', '0' );
ini_set( 'display_startup_errors', '0' );
}
add_action( 'init', 'scseed_hide_php_errors_frontend', 1 );
}#errors#hardening#php#privacy#security