Section 7.1. Introduction


7.1. Introduction

You can reduce the number of errors in your application by using good programming practices; however, many factors cause errors that are beyond our control in a script. Network outages, full hard disks, hardware failure, bugs in other PHP components, or programs your application interacts with can all cause errors that are not due to any fault of your PHP code.

If you do nothing to deal with such errors, PHP's default behavior is to show the error message to the user, along with a link to the page in the manual describing the function that failed, as well as the file name and line of the code that triggered the error. For most errors, PHP keeps running after displaying this message. See Figure 7.1.

Figure 7.1. PHP error message.


This error message is really meant for you, the developer, not for the users of your site. Users would appreciate a page explaining, in layman's terms, what went wrong and have no interest in documentation links or the location of your code.

PHP provides a number of options to deal with such errors in a better way. After you finish reading this chapter, you will have learned

  • The various types of errors your users might face

  • What options you, as the developer, have within PHP for handling them

  • How to write your own error handlers

  • Converting between different error to reporting mechanisms



    PHP 5 Power Programming
    PHP 5 Power Programming
    ISBN: 013147149X
    EAN: 2147483647
    Year: 2003
    Pages: 240

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