Website Without PHP
US
Menu

How to Show PHP Errors and Read the Error Log

Your site hides technical error messages from visitors, which is right for a live site, but it also means a broken page can look blank without telling you why. To find the reason, you read the error logAn error log is a file where your website's software writes down what went wrong, with the time and place. It is the first thing to check when a site breaks. instead of showing errors on screen, because on-screen messages can show visitors details about your server. The steps below show how to do that safely.

To show PHPPHP is a programming language that builds your web pages on the computer that hosts your site, just before they reach the visitor. WordPress runs on it. errors, you switch on the display_errors setting, but the safer way to see them is the PHP error log, which records the same messages in a file that visitors never see. Most servers hide errors on screen by default, which is why a broken page often looks blank.

What the settings do

PHP has a few settings that control error handling. The display_errors setting decides whether messages are printed into the page. The log_errors setting decides whether they are written to a log file. The error_reporting setting decides which types of messages are included, from notices up to fatal errors. A production site should log errors and not display them. A development or stagingA staging environment is a private copy of your website where you try updates first, so any mistakes happen there and not on the live site. copy can display them to make debugging faster.

Why displaying errors on a live site is risky

On-screen messages often include file paths, function names and sometimes details about the setup. Every visitor can read them, and they can also break the page layout. That is why you should not leave display switched on for a public site. If you must look at the output on a live site, do it briefly and switch it off again right after.

Where to find the error log

Many hostingWeb hosting is the service that keeps your website's files on a computer that is always online, so visitors can open your site at any time. panels have an error log section. The log is often a file named error_log or php_errors.log, placed in the site folder or in a logs folder outside it. Your host can tell you the exact location. On WordPressWordPress is free software for building and editing a website in your browser. It is written in PHP, so it builds each page when someone visits. you can set WP_DEBUGWP_DEBUG is a WordPress setting that makes hidden errors visible or saves them to a file, which helps find out why a site shows a blank page. and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false. By default the log is wp-content/debug.log, which is usually reachable from the web, so point WP_DEBUG_LOG to a path outside the web root or delete the file when you are done.

How to read a log entry

Each entry normally holds a time, the error type, the message, the file path and the line number. Start at the newest lines. Look for the type first: notice, warning, deprecatedA deprecation is an early warning that a feature still works today but will be removed in a future PHP version, so code using it must be changed in time., parse error or fatal error. Then open the file and line mentioned. Repeated entries with the same line are the ones worth fixing first.

What you can try yourself

First, take a backupA backup is a separate copy of your website's files and database, so you can bring the site back after a mistake, a hack or a failed update.. Second, locate the log in your hosting panel and read the latest entries. Third, if there is no log, enable logging to a file, reproduce the problem once, and read the new entry. Fourth, if you need to see messages on screen, do it on a staging or local copy. Fifth, switch debugging off again when you are finished and delete old debug logs. Keep passwords and keys out of anything you share.

When the PHP versionA PHP version is a numbered edition of PHP, like 8.3. Each edition is looked after for a limited time, then gets security fixes only, then nothing. is the cause

If entries mention deprecated features or removed functions after an update, the PHP version is probably involved. The supported versions page on this site explains which versions the PHP project still maintains.

When to get help

If you cannot reach the log, or the entries point at code you cannot change, ask for help. At Website Without PHP a human replies within 1 business day. A rush repair starts from $425, excluding VAT.

Frequently asked questions

Is it safe to turn on display_errors?

On a staging or local copy, yes. On a live site only very briefly, because every visitor can read the messages. Logging to a file gives you the same information without that risk.

Where is the PHP error log on shared hosting?

Usually in the hosting control panelA hosting control panel, such as cPanel, Plesk or DirectAdmin, is the web page where you manage your domain, email, databases and PHP version. under a heading such as errors or logs, or as a file named error_log in the site folder. If you cannot find it, ask your host for the location. They can also tell you whether logging is switched on.

Why is my error log empty?

Logging may be switched off, the log may be written to another location, or the problem is not a PHP error at all, for example a web serverA web server is the program, such as Apache, Nginx or LiteSpeed, that answers when a visitor opens your site and sends back the page and files. or cachingA cache is a store of ready-made copies, such as finished pages, so a website or browser can show something instantly instead of building it again. issue. Reproduce the problem once after enabling logging and look again.

Should I delete old log files?

Yes, once you have read them. Old logs take disk space and can contain paths and other details you do not want lying around. On WordPress this applies especially to wp-content/debug.log, which is usually reachable from the web.

Related pages

Useful next steps

Related pages

  1. Domain
  2. Check
  3. Result
  4. Report

Which PHP version does your site run?

Enter your domain. We read only what your site already sends in public: the headers and the top of the homepage. No scan, no login. We keep the domain and the result, never your IP address.