PHP errors and warnings displayed on a live website expose internal code details to visitors and can make your site appear broken. Hiding them from the browser while keeping error logging active means you can still diagnose problems without affecting the visitor experience.
There are four places you can control PHP error display: php.ini, your .htaccess file, wp-config.php (for WordPress sites) or directly inside a specific PHP file. Choose the method that matches your level of access and the scope of the change you need.
The php.ini file controls PHP behaviour across your entire hosting account. Setting display_errors to Off here is the broadest approach and affects all PHP files on your account. The expose_php directive also prevents PHP version information from being sent in HTTP response headers, which reduces the information available to anyone probing your server.
Locate your php.ini file in your hosting account’s root directory or create one if it does not exist, then add or update the following lines:
expose_php=Off
display_errors=Off
Save the file. Changes take effect on the next PHP request without needing a server restart on most shared hosting environments.
If you do not have access to php.ini, you can set PHP flags from your .htaccess file instead. This method applies to the directory containing the file and all subdirectories beneath it, making it a good option when you want to target a specific site rather than your whole account.
.htaccess inside your public_html directory. If it does not exist, create a new file with that name. Make sure hidden files are visible by enabling Show Hidden Files in File Manager settings.php_flag display_errors off

WordPress has its own debug constants that interact with PHP error display. Setting these correctly in wp-config.php prevents errors from appearing on the front end while keeping WordPress’s own debug log available for troubleshooting.
public_html directory and click Edit.WP_DEBUG, WP_DEBUG_DISPLAY or display_errors to avoid conflicts./* That's all, stop editing! */:ini_set('display_errors', 'Off');
ini_set('error_reporting', E_ALL);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
error_reporting to E_ALL alongside display_errors Off means all error types are still captured in your server log rather than silently discarded.When you only need to suppress errors on one particular page or script, you can add a single line at the top of that PHP file. This overrides any server-level setting for that file only and does not affect the rest of your site.
Open the PHP file you want to modify and add the following as the first line after the opening <?php tag:
error_reporting(0);
Save the file. Errors on that page will no longer be shown to visitors.
If errors continue to appear after editing .htaccess or php.ini, a conflicting directive in another file may be overriding your change. PHP processes multiple configuration sources in a set order, and a later source can override an earlier one.
php.ini file exists in the same directory as the affected script and contains a conflicting display_errors=On line.ini_set('display_errors', 'On') or error_reporting(E_ALL) and remove those lines.Some hosting environments run PHP as a CGI or FastCGI process rather than as an Apache module. In those configurations, php_flag directives in .htaccess are not supported and will trigger a 500 Internal Server Error.
php_flag line from .htaccess to restore your site.php.ini file in the same directory instead, with display_errors=Off.You have now hidden PHP errors from your site’s visitors using one of four methods: a server-wide php.ini directive, an .htaccess flag, WordPress debug constants in wp-config.php or a per-file error_reporting(0) call. In each case, errors are suppressed in the browser without disabling logging on the server.
Review your server error log periodically to catch any issues that are now hidden from the front end. For WordPress sites, our guides on removing malware from WordPress and creating a phpinfo file can help you investigate underlying problems. If you need to change which PHP version your site runs, see our guide on changing your PHP version in cPanel.
Our PHP hosting plans give you full control over your PHP configuration, including access to php.ini settings from your control panel.
Launch your website with our reliable cPanel hosting with unlimited bandwidth and expert support.
Get cPanel Hosting