Common PHP Errors and How to Fix Them
Browse all documented PHP errors with detailed explanations, root causes, and step-by-step fixes.
Trying to access array offset on value of type null in /var/www/html/data.php on
This error occurs when a developer tries to access an element of an array or object using a key or property, but the val…
Attempt to assign property of non-object in /var/www/html/controllers/UserContro
This error occurs when you're trying to access a non-object property using object syntax. It could be due to a failed da…
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate en
This error occurs when you attempt to insert a duplicate value into a column that has a unique constraint, such as a pri…
Notice: Undefined variable: database_connection in /var/www/html/database_operat
This error occurs when a variable has not been declared or initialized before it's being used in a script.…
Cannot modify header information - headers already sent in /var/www/html/index.p
This error occurs when you're trying to send HTTP headers after output has already been sent to the browser. In PHP, hea…
Undefined variable: product in /var/www/html/cart.php on line 27
This error occurs when a variable is used before it is declared or assigned a value.…
The controller method 'render' is not defined in the controller 'App\Controllers
This error is thrown when a controller method is not found or is not defined in the controller class.…
Warning: Cannot redeclare class Foo in /var/www/html/autoloader.php on line 55
This error occurs when a PHP script attempts to declare a class with the same name in a different scope, usually due to …
Cannot pass parameter 2 by reference in /var/www/html/api.php on line 56
This error occurs when trying to pass a value by reference in a function parameter that has been declared to be passed b…
Unexpected '}' at end of file in /var/www/html/script.php on line 1
This error occurs when the PHP interpreter encounters unexpected syntax at the end of a file. In this case, it's a closi…
Undefined property: stdClass::$email in /var/www/html/user.php on line 56
This error occurs when a property or method is not defined in an object. It is often caused by typos or incorrect object…
Fatal error: Uncaught Error: Cannot pass string to argument 1 of fgets(), expect
This error occurs when a PHP function that expects a resource (like a file pointer) is passed a string instead.…
Have a PHP error that's not listed? Get an instant explanation.
Explain Another Error