7.2. Types of Errors

7.2.1. Programming Errors

Sometimes errors occur due to errors in our code. In some ways, these are the easiest errors to deal with because they can be uncovered mostly by straightforward testing, simply by trying out all the operations your application provides. Handling them is just a matter of correcting the code.

7.2.1.1. Syntax/Parse Errors

Syntax errors and other parse errors are caught when a file is compiled, before PHP starts executing it at all

<?php

    print "Hello!\n";
    <gobbledigook/>

    ?>

This example contains an XML tag where PHP expects to find code. Running this results in an error:

Parse error: parse error in test.php on line 4

As you can see, the script did not even print Hello! before displaying an error ...

Get PHP 5 Power Programming 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.