PHP Debugging Techniques

Debugging a PHP script—debugging it efficiently, at least—boils down to understanding the normal causes of errors. Table 9.1 lists the likely reasons for the most common PHP errors.

Table 9.1. These are some of the most common errors you’ll see in PHP, along with their most probable causes.
Common PHP Errors
Parse errorMissing semicolon, unbalanced curly braces, parentheses, or quotation marks, or use of an unescaped quotation mark in a string.
Empty variable valueForgot the initial $, misspelled or miscapitalized the variable name, inappropriate variable scope, or the register_globals setting is turned off.
Undefined variableReference made to a variable before it is given a value.
Call to undefined function ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.