Skip to content
PHP and Laravel3 min read

PHP Fatal error: how to read it and fix it

PHP Fatal error: Uncaught Error

Short answer

A PHP Fatal error means PHP hit a problem it can't recover from and stopped the whole script, so visitors see a blank page or a 500 error. The message gives the error type, file and line; the fix depends on the type: an undefined function, a missing class, exhausted memory, or null where an object was expected.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What the error means
  2. Common causes
  3. How to fix it
  4. Prevention
  5. On ArabyHost

When a fatal error hits, PHP stops at the reported line and never renders the rest of the page. On a live site, where error display is (rightly) off, visitors get a blank page or a 500 error, and WordPress shows “There has been a critical error”. So every fix starts with the error log.

What the error means

A full message looks like this:

PHP Fatal error:  Uncaught Error: Call to a member function format() on null in /home/user/public_html/app/Report.php:42
Stack trace:
#0 {main}
  thrown in /home/user/public_html/app/Report.php on line 42
  • Uncaught Error: the error type. It can also be TypeError, ArgumentCountError or ValueError.
  • The text after it: what went wrong. This is the key part.
  • Path and line: where execution stopped.
  • Stack trace: the chain of calls that led there. The first frame inside your own code, not inside vendor, is usually where to look.

Common causes

Part of the message Cause Fix
Call to undefined function PHP extension not enabled, or function removed Call to undefined function
Class "..." not found Composer autoload or wrong path Class not found
Allowed memory size ... exhausted Out of memory Allowed memory size exhausted
Maximum execution time ... exceeded Ran too long Raise the limit or split the task
Call to a member function x() on null Variable is null instead of an object Check the object exists before using it
Cannot redeclare function Same function defined twice function_exists() or require_once
must be of type array, null given PHP 8 rejects the wrong value type Fix the value or update the code

How to fix it

  1. Find the full message: in cPanel open Metrics › Errors, or open the error_log file in the script’s folder via Files › File Manager.
  2. Read the file, line and stack trace, and find the first frame that belongs to your code or plugin.
  3. Ask what changed: a plugin update, a new deploy, or a PHP version switch. If it started after changing versions, switch back temporarily under Software › Select PHP Version, then fix the code.
  4. Fix by type using the table above. Example for the null case:
$user = findUser($id);

if ($user === null) {
    http_response_code(404);
    exit('User not found');
}

echo $user->getName();
// or in PHP 8: echo $user?->getName();
  1. Hide errors from visitors, log them instead: in Software › MultiPHP INI Editor set display_errors to Off and log_errors to On. Showing errors on a live site leaks file paths and other sensitive details.

Prevention

  • Run the same PHP version locally as on the server, and declare it in composer.json, for example "php": "^8.2".
  • Test major updates on a staging copy before the live site.
  • Read the migration notes when moving between PHP versions; see choosing a PHP version.
  • Check the error log regularly: today’s deprecation warnings become tomorrow’s fatal errors.

On ArabyHost

You can choose PHP 8.1, 8.2 or 8.3 per site and switch back if an error appears after a change. The Araby AI assistant in the panel reads the error log and explains the fatal error and how to fix it. On AI/Developer plans you get SSH jailed in CageFS with Git and Composer, so you can follow the log live with tail -f error_log. JetBackup keeps a daily backup to return to if an update breaks the site.

FAQ

What's the difference between a Fatal error and a Warning in PHP?

A Warning doesn't stop the script: execution continues and you may get partial output. A Fatal error halts execution right at the reported line, and nothing after it runs.

Why did fatal errors appear after upgrading to PHP 8?

PHP 8 turned many old warnings into TypeErrors and removed legacy functions such as each() and create_function(). Update the code or plugin to a version that supports PHP 8.

Where is the error message if the page is blank?

In cPanel under Metrics › Errors, or in the error_log file in the script's folder. Laravel logs to storage/logs/laravel.log, and WordPress to wp-content/debug.log when WP_DEBUG_LOG is on.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.