Categorized | News

Error Handling Ideas from PHP mag

Posted on 06 August 2003 by Demian Turner

If you are not fortunate enough to be a subscriber to PHP magazine, you may want to take a look at this great error handling class presented last issue by  Peter James.

The class introduces a few interesting programming ideas, like inner functions and using them to override PHP’s default error handling.

Bookmark and Share

3 Comments For This Post

  1. tychay Says:

    At first glance the inner function idea seems like a lot of
    work to get around a feature built into PHP.

    He could have just done:

    function start_handler() {
       set_error_handler(array('ErrorHandler','error_handler'));
    }
    

    Of course he has an excludes array and a line number counter
    which are static parameters so you may need to revise the code
    to:

    function start_handler() {
       set_error_handler(array(&this,'error_handler'));
    }
    

    Someone tell me why I need an inner function and two
    globals?

    Methinks some people need to spend more time reading the
    (very incomplete!) documentation at PHP.net!

  2. petej Says:

    If you read the documentation in the class *and* on php.net for set_error_handler(), you will see that it did not accept anything but a standard function name before php 4.3… And this was written well before php 4.3.

    Thanks,
    Pete.

  3. petej Says:

    Oops, I just noticed that the version posted here has no comments.

    Take a look at http://php.shaman.ca/eh/error_handler.phps

Leave a Reply

Categories

Books

Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists

Facebook