Specifications

This chapter will deal with debugging PHP scripts. If you have been through some of the
examples in the book or used PHP before, you will probably have developed some debugging
skills and techniques of your own. As your projects get more complex, debugging can become
more difficult. Although your skills improve, the errors are more likely to involve multiple
files, or interactions between the code of multiple people.
Topics in this chapter include
Programming error types
Syntax errors
Runtime errors
Logic errors
Error messages
Error levels
Triggering your own errors
Handling errors gracefully
Remote debugging
Programming Errors
Regardless of which language you are using, there are three general types of types of program
errors:
Syntax Errors
Runtime Errors
Logic Errors
We will look briefly at each before discussing some tactics for detecting, handling, avoiding,
and solving errors.
Syntax Errors
Languages have a set of rules called the syntax of a language, which statements must follow in
order to be valid. This applies to both natural languages, such as English, and programming
languages, such as PHP. If a statement does not follow the rules of a language, it is said to
have a syntax error. Syntax errors are often also called parser errors when discussing inter-
preted languages, such as PHP, or compiler errors when discussing compiled languages, such
as C or Java.
If we break the English languages syntax rules, there is a pretty good chance that people will
still know what we intended to say. This usually is not the case with programming languages.
Building Practical PHP and MySQL Projects
P
ART V
478
29 7842 CH23 3/6/01 3:41 PM Page 478