Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199908

Re: [PHP3] 0 is not a result From: Steve Edberg (sbedberg <email protected>)
Date: 08/24/99

At 12:24 AM +1000 8/25/99, Jason Brooke wrote:
> > While we are on the subject is there any way to catch fatal errors.
> >
> > In perl, eval cound be used for this, and the fatal error message is
>return
> > in a variable $! or @! or something.
> >
> > Can/will php support catching such errors.
> >
> > Sam
>
>
>Errors which are likely to halt script execution or something else ugly can
>be placed inside conditional statements so that if they fail, the 'else'
>catches them and you can perhaps log the failed event or try something else
>instead.
>

You can also use $php_errormsg (track_errors must be 'On' in
php3.ini, or set it on in httpd.conf or .htaccess); this stores the
last error message generated.

        $something = @$func_name($param1, $param2);

        if (!$something) {
                $error = $php_errormsg;
                ...
                echo $error;
                ...
        } else {
                ...
        }

(This assumes that any function named by $func_name will never return
false as a valid value). Here, if there is an error - whatever
$func_name is set to is not an existing function, or it doesn't
accept the number/types of arguments specified) you can do some error
handling of your own design.

Of course, for mysql errors there is always mysql_error() and
mysql_errno(), and I presume there are analogues for other DBs.

See
        http://www.php.net/manual/feature-error-handling.php3
and
        http://www.php.net/manual/configuration.php3

-steve

+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg University of California, Davis |
| sbedberg <email protected> (530)754-9127 |
| Computer Consultant http://aesric.ucdavis.edu/ |
+---------------- said t e lawrence, picking up his fork ----------------+

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>