Skip to main content

Error Log

Updated over 3 months ago

When you run PHP scripts on your server, errors can occur. To understand and fix them, the PHP error.log is a valuable resource. This file records all error messages and warnings that occur during the execution of your PHP scripts. Here’s how to find the error.log and what you can do with it.

What is the PHP error.log?

The PHP error.log is a log file that collects all PHP errors and warnings generated while your code is running. It helps you pinpoint exactly where errors occur in the code, so you can fix them quickly.

How do I find the PHP error.log?

The error.log file is usually located on your web server and can be accessed via FTP or through your hosting provider’s control panel. At Hoststar, you can access the error.log via your FTP account.

Common PHP error messages in the error.log

Parse Error: Syntax Error

Meaning:
There is a syntax error in the PHP code, such as a missing semicolon or an unclosed bracket.

Example:

Parse error: syntax error, unexpected 'echo' (T_ECHO) in /path/to/file.php on line 10

Solution:
Check the line indicated in the error message and correct the syntax error.

Fatal Error: Allowed Memory Size Exhausted

Meaning:
The PHP script has exceeded the allocated memory limit.

Example:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2097152 bytes) in /path/to/file.php

Solution:
Increase the memory limit in your PHP configuration or optimize your code to reduce memory usage.

Fatal Error: Maximum Execution Time Exceeded

Meaning:
The PHP script has exceeded the maximum allowed execution time.

Example:

Fatal error: Maximum execution time of 30 seconds exceeded in /path/to/file.php

Solution:
Optimize the script to reduce execution time, or increase the maximum execution time in your PHP configuration.

Did this answer your question?