Overview

   

Bugs are an everyday part of a programmer's life. We all forget a semicolon or an end bracket at one time or another. Sometimes, we spell a variable name wrong and wonder why the value that is supposed to be showing up on the screen keeps coming up blank. Other times you wonder what gremlins are lurking on the database server because the data just isn't going in (or coming out) the way you intended it. How many times have you looked at a piece of code over and over and wondered why in the heck your program isn't working?

Some bugs the kind bugs, the ones who don't mind being squashed out will immediately tell you that they are there, by way of the PHP parser. For example, bugs like the ever-present "Parse error" or even the occasional "Warning: Division by zero" let you know on which line they occurred. It's easy enough for you to fix them: You just open your script, add a semicolon here, change the spelling of a variable there, and you are on your way.

Users, unfortunately, don't have this luxury. Have you ever spent an hour or so on some online shopping site, carefully picking out some nice gear for yourself, and going through a long and arduous multipage form to provide your address and credit information before finally clicking that glossy submit button, only to have the page display in plain type "Script Error Database Connection Failed On Line 193" and nothing else? You just gave these people your credit card number and when their script dies all you see is "Script Error…."

Better sites, smarter sites that is, YOUR site should not do that. If there is an error, it would be nice to at least inform users that something went a little awry and the administrators have been notified. Maybe even a note that says the order went through (or didn't). Do you want to subject users of your site to ugly error messages that provide them with no information? Of course not.

In addition, errors can display information that could be useful to malicious users who are trying to crack into your site. Errors typically display file paths, database server information, and other information that could compromise the security of your site.

This chapter explains PHP's error and logging functions.


   
Top


Advanced PHP for Web Professionals
Advanced PHP for Web Professionals
ISBN: 0130085391
EAN: 2147483647
Year: 2005
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net