NYCPHP Meetup

NYPHP.org

Anyway to report errors back from includes/requires?

Jon Baer jonbaer at jonbaer.net
Tue Jun 3 13:13:43 EDT 2003


I know PHP 5 will have common try/catch block is there anyway to do it <
5.0?

I did some tests with set_error_handler and realize the error does not come
up the chain ... how would an example like this translate (from Java to
PHP):

try {
    queryPoll(); // does SQL and *may* timeout
} catch (Exception e) {
    System.out.println("Sorry, the poll was not available.");
}

I was thinking this would do it in PHP:

    error_reporting(0);
    set_error_handler("handle_error");
    include("poll.php");

    function handle_error ($errno, $errmsg, $filename, $linenum, $vars) {
        if ($filename == "poll.php") { echo "Sorry, the poll was not
available."; }
    }

I don't think Im understanding error reporting correctly.

- Jon




More information about the talk mailing list