Aller au contenu

Finding PHP error logs and showing or hiding errors

Ce contenu n’est pas encore disponible dans votre langue.

When a PHP site shows a blank page, a 500 error or “There has been a critical error on this website”, the PHP error log usually tells you why.

PHP error logging is on by default. PHP writes errors to a file called error_log in the same folder as the script that failed, for example:

  • public_html/error_log for your main website
  • public_html/wp-admin/error_log for errors in the WordPress dashboard
  • public_html/yourotherdomain.com/error_log for an addon domain

To read it:

  1. In cPanel, open File Manager and go to your website’s folder.
  2. Open error_log with View or Edit. The newest errors are at the bottom.

Each line shows the date, the type of error, the message, and the file and line number, for example:

[15-Oct-2026 09:12:44 UTC] PHP Fatal error: Uncaught Error: Call to undefined function mb_strlen() in /home/cpuser/public_html/wp-content/plugins/example/file.php:42

The file path tells you which plugin, theme or script caused the error. See Common PHP errors for what the messages mean.

error_log files can grow large and use your disk space. Once you’ve fixed the problem, it’s safe to delete them. PHP creates a new one when the next error happens.

Show errors on the page while you fix a problem

Section titled “Show errors on the page while you fix a problem”

By default, errors aren’t shown to visitors. This keeps file paths and other details private. To see errors on the page while you work:

  1. In cPanel, open Select PHP Version → Options.
  2. Set display_errors to On.
  3. Reload the page that has the problem.
  4. Set display_errors back to Off when you’re done.

For one folder only, add php_flag display_errors On to that folder’s .htaccess file. See Custom PHP settings for one folder.

In WordPress, the safest way is to log errors to a file without showing them to visitors. Add these lines to wp-config.php above /* That's all, stop editing! */:

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

Errors are then saved in wp-content/debug.log. Set WP_DEBUG back to false when you’re done.

error_reporting in Select PHP Version → Options controls which errors PHP reports. The default reports all errors except “deprecated” notices, which warn about code that will stop working in a future PHP version. Choose E_ALL to see those too, for example before upgrading PHP.

You can set log_errors to Off in Select PHP Version → Options, but we don’t recommend it: without a log, problems are much harder to find. It’s better to fix the errors filling the log.

Cette page vous a-t-elle aidé ?