Debug PHP — PHP

Debug PHP code: 10 levels of warnings, notices, exceptions and var_dump. A PHP debugging game that trains your eye for errors.

What you learn in this game

PHP needs every statement to end with a semicolon (;). Without it, PHP cannot tell where the statement ends and refuses the whole file with a Parse error, before a single line runs.

A logic error is a bug that does not make the program crash but makes its result wrong. It often comes from a comparison operator mixed up or a condition turned around.

Unlike JavaScript, which joins strings with +, PHP uses the dot operator (.). It is a common source of bugs for people new to PHP.

Arrays in PHP (and in almost every programming language) start at index 0. An array of 3 elements has the indexes 0, 1 and 2. Reading an index outside those gives a warning and an empty value (null).

In PHP, the arrow operator (->) reaches an object's properties and methods. That differs from JavaScript and Java, which use a dot (.). In PHP the dot joins strings instead.