Debugging practice

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

 

Next chapter: Coding style >>

Previous chapter: phpinfo()

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar