Hudzilla.org - the homepage of Paul Hudson
Contents > Writing PHP Wish List | Report Bug | About Me ]

19.9     Debugging practice

This is NOT the latest copy of this book; click here for the latest version.

As you saw in the last chapter, there are quite a few ways to help you track down problems in your code. Having said that, the very first thing you should do upon seeing an error message in one of your scripts is to visually examine the relevant source code - even if only for a few moments. Not only does this refresh your memory about what is going on in that particular area, but very often you will find the problem is something trivial that you can spot and fix in seconds.

In order to make this point clear, and also to hopefully train up your brain in spotting fairly straightforward bugs, cast your eyes over these three simple scripts and find the obvious bugs:

<?php
    
print "Hello world!
?>
<?php
    
print "Hello world!":
?>
<?php
    
print "Hello world!';
?>




<< 19.8.13 phpinfo()   19.10 Coding style >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is zero plus ten?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow