Coding⏱️ 4 min read📅 2026-06-11

How to Fix: How do I disable ALL error messages via php.ini?

Disable all PHP error messages with php.ini settings.

Quick Answer: Try setting 'display_errors' to 'off', but ensure 'log_errors' is also set to 'on' for logging purposes.

Despite proper configuration of error reporting settings, you may still encounter issues where error messages are displayed despite being set to 'off'. This can be frustrating and affect your ability to troubleshoot and debug your PHP application. In this guide, we will walk through the steps to disable all error messages in PHP using the php.ini file.

Disabling all error messages can help improve performance and reduce clutter in your error logs. However, it's essential to note that disabling errors may also prevent you from identifying and fixing issues with your application.

⚠️ Common Causes

  • The primary reason for displaying error messages despite proper configuration lies in the php.ini file. If the 'error_reporting' setting is not correctly set or if there are other global settings overriding it, errors may still be reported.
  • Another alternative reason could be the presence of custom error handlers or third-party libraries that override the default error reporting settings.

✅ Best Solutions to Fix It

Modifying php.ini to disable all error messages

  1. Step 1: Step 1: Locate the php.ini file on your server. The location may vary depending on your PHP version and configuration.
  2. Step 2: Step 2: Open the php.ini file in a text editor and navigate to the 'error_reporting' setting. Ensure that it is set to 'E_ALL & ~E_STRICT' or 'E_ALL & ~E_NOTICE'. This will disable all error types except for Strict Standards errors.
  3. Step 3: Step 3: Set the 'display_errors' setting to 'Off' to prevent displaying of error messages on the screen.
  4. Step 4: Step 4: Set the 'log_errors' setting to 'On' and specify a log file path to store error logs. This will help you keep track of any errors that occur during runtime.
  5. Step 5: Step 5: Save the changes to the php.ini file and restart your PHP service or application server.

Using .htaccess to disable all error messages

  1. Step 1: Step 1: Create a new file named '.htaccess' in the root directory of your website. If you don't have access to this file, you may need to create it manually or use a different method.
  2. Step 2: Step 2: Add the following line to the .htaccess file: `php_value error_reporting E_ALL & ~E_STRICT`. This will set the 'error_reporting' setting globally for your website.
  3. Step 3: Step 3: Add the following line to the .htaccess file: `php_flag display_errors Off`. This will prevent displaying of error messages on the screen.
  4. Step 4: Step 4: Save the changes to the .htaccess file and restart your web server.

✨ Wrapping Up

By following these steps, you should be able to disable all error messages in PHP using the php.ini file or by utilizing a .htaccess configuration. Remember to carefully review and test your configurations to ensure that errors are properly handled and not masked.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions