NYCPHP Meetup

NYPHP.org

[nycphp-talk] Anyway to report errors back from includes/requires?

Ophir Prusak ophir at prusak.com
Tue Jun 3 15:39:23 EDT 2003


see http://www.php.net/manual/en/ref.errorfunc.php for more info on how to
catch errors.

also you can add the at sign "@" before the function call.
do this (copied from http://us2.php.net/manual/en/function.include.php)

$success = @include($yourinclude);
if (!$success) { print "Can't find page $yourinclude"; }

Ophir
Hire me :)

----- Original Message ----- 
From: "Jon Baer" <jonbaer at jonbaer.net>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Tuesday, June 03, 2003 1:14 PM
Subject: [nycphp-talk] Anyway to report errors back from includes/requires?


> 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
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>




More information about the talk mailing list