Exercise : Buggy PHP

The following PHP pages each contain one or more bugs. The bugs could be syntax errors or incorrect logic. Look at each page, find the bug(s), and correct the errors.

  1. buggy page 1 (source) - variables, strings, if/else
  2. buggy page 2 (source) - variables, if/else, comments
  3. buggy page 3 (source) - variables, for loops, string concatenation
  4. buggy page 4 (source) - arrays, foreach
  5. buggy page 5 (source) - arrays, foreach

Exercise debugging tips

Exercise solutions

  1. buggy page 1, fixed
  2. buggy page 2, fixed
  3. buggy page 3, fixed
  4. buggy page 4, fixed
  5. buggy page 5, fixed