19.9 Debugging practiceThis 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!';
?>
|
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!
|