PHP errors and warnings help with troubleshooting during development but should not be displayed on live websites, as they may expose sensitive information and affect user experience. This article explains different methods to hide PHP errors based on your needs.
Important: Hiding errors does not resolve the issue; errors should remain enabled in development environments and disabled only on production sites.
Methods to Hide PHP Errors and Warnings
Below are the most commonly used methods to conceal PHP errors. Choose the method based on your website type and requirements.
Method 1: Hide PHP Errors Using the .htaccess File (Entire Website)
This method hides PHP errors across the entire website and is suitable for Apache-based servers.
Steps:
- Log in to your hosting control panel.
- Open File Manager and navigate to the public_html directory.

- Locate the .htaccess file. If it does not exist, create a new file named .htaccess.

- Add the following line to the file:
php_flag display_errors off
- Save the changes.

PHP errors and warnings will no longer be displayed on your website.
Method 2: Hide PHP Errors on a WordPress Website (Recommended for WordPress)
For WordPress-based websites, errors can be controlled using the wp-config.php file.
Steps:
- Open File Manager and navigate to public_html/wp-config.php.
- Locate the following line (if it exists):
define(‘WP_DEBUG’, true);
- Replace it with the following configuration
define(‘WP_DEBUG’, false); define(‘WP_DEBUG_DISPLAY’, false); ini_set(‘display_errors’, ‘Off’);
- Save the file.
PHP errors and warnings will now be hidden from the front end of your WordPress website.
Method 3: Hide PHP Errors for a Specific Page
If you want to conceal PHP errors only on a specific page, you can modify the corresponding .php file.
Steps:
- Open File Manager and locate the required .php file.
- Add the following line at the top of the file:
error_reporting(0);
- Save the changes.
PHP errors will now be hidden only on that specific page.
Best Practices and Notes
- Always keep error reporting enabled in development environments.
- Use logs to monitor PHP errors instead of displaying them publicly.
- Incorrect configuration changes may result in a 500 Internal Server Error.
- Take a backup of files before making any changes.
This concludes the guide on hiding PHP errors and warnings. Using the appropriate method helps prevent sensitive information from being displayed, ensuring a secure and professional website. For further assistance, contact your hosting support team.