• Wednesday, February 25, 2026

Knowledge Base

PHP Errors and Warnings

PHP Errors and Warnings

PHP errors can break your website or display error messages to visitors. Here's how to troubleshoot them.

Types of PHP Errors

  • Fatal Error: Stops script execution - site won't load
  • Parse Error: Syntax mistake - code can't be interpreted
  • Warning: Script continues but something unexpected happened
  • Notice: Minor issues, script runs normally
  • Deprecated: Using features that will be removed in future PHP versions

Viewing PHP Errors

Method 1: Error Log

In DirectAdmin:

  1. Go to Error Log
  2. View recent PHP errors with line numbers

Method 2: Enable Display (Temporarily)

Add to your PHP file temporarily:

ini_set('display_errors', 1);
error_reporting(E_ALL);

Remove after debugging!

Common Errors and Fixes

Memory Exhausted

Fatal error: Allowed memory size exhausted

Solution - increase in php.ini or .htaccess:

php_value memory_limit 256M

Maximum Execution Time

Fatal error: Maximum execution time exceeded

Solution:

php_value max_execution_time 300

Undefined Variable/Index

Notice: Undefined variable/index

Solution: Check variable exists before using:

$value = isset($_POST['field']) ? $_POST['field'] : '';

Class Not Found

Fatal error: Class 'ClassName' not found

Solution: Ensure file is included/required or autoloader is working.

PHP Version Compatibility

Some code may not work with newer PHP versions:

  • Try switching PHP version in DirectAdmin
  • Check if your scripts/CMS support your PHP version
  • Update deprecated code

Hide Errors in Production

Never show errors to visitors. Use:

display_errors = Off
log_errors = On

Errors will be logged but not displayed.