One of the first things PHP does when you ask it to execute a piece of code is a syntax check. Basically, it goes through the code and makes sure that it conforms to the basic grammar of the language. Some of the questions the parser asks include:
Does a semicolon terminate every statement?
Do all the function calls reference functions that actually exist in PHP's namespace?
Are all language constructs in the code known to the parser?
If any problems are detected, the interpreter will generate an error message that is often detailed enough to pinpoint the problem and fix it. If you are reading the chapters of this book in order, you will already have seen the output of the syntax check in the chapter on Subversion. If you recall, we created a pre-commit hook script that checks the syntax of PHP scripts before they are being allowed to be committed to the repository.
The syntax check happens automatically when the interpreter starts up, but we can also invoke...