PHP errors should normally be logged for diagnosis without being shown to visitors. Hiding the messages protects technical details, but it does not resolve the underlying problem.

Configure web PHP settings

Use the hosting panel’s PHP settings or the appropriate PHP configuration for the website’s active handler. Set:

display_errors = Off
display_startup_errors = Off
log_errors = On
error_reporting = E_ALL

Keep the error log in a private location and restrict its access. An administrator may need to apply or reload some settings. Check the website’s PHP environment rather than assuming command-line PHP uses the same configuration.

A php_flag directive in .htaccess only works with compatible Apache PHP configurations and can cause a 500 error with other handlers. Do not paste it into every site.

WordPress settings

Back up wp-config.php and edit existing constants, avoiding duplicates. Before the stop-editing line, normal production settings can include:

define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

Keep server-side PHP logging configured separately. For a controlled debugging session, WordPress has its own debug logging options; ensure any resulting log is not publicly accessible.

Check the result

Test the site and inspect the private error log. Do not use error_reporting(0) as a general fix, because it suppresses useful diagnostics. Runtime changes inside a script also cannot reliably hide every startup or parse error, so apply the appropriate configuration settings.