NYCPHP Meetup

NYPHP.org

[nycphp-talk] NEW PHundamentals Question - Error Handling

David Mintz dmintz at davidmintz.org
Mon May 10 11:55:20 EDT 2004



No discussion is complete without mentioning PHP's native error and
logging functions (http://us3.php.net/manual/en/ref.errorfunc.php),
especially set_error_handler(), error_reporting(), trigger_error()

No discussion is complete without mentioning PEAR_Error which offers a lot
of flexible and convenient means of error handling
(http://pear.php.net/manual/en/core.pear.pear-error.php)

One of the criticims of languages that don't have real exception handling
(try/catch/finally) is that checking the return value of every call gets
tedious and hard to read. One of the things I like about Pear is that you
can set an error handling callback function, and then go ahead and run a
few lines of e.g. database stuff without bothering line-by-line.

Another point that bears mentioning -- since this is a Fundies thread --
is whether and how much error output to display it the browser in
development versus production, from the security standpoint as well as
style. Development:  verbose and informative. Production: apologetic and
vague.

Perhaps it also bears mentioning by way of Fundies that if you have error
reporting on and warnings on, you can still supress error output on a
per-function-call basis by prepending an @ to the function name.


I would (and could) elaborate on all of the above but I just wanted to get
a shot in before someone else beat me to it (-:

---
David Mintz
http://davidmintz.org/

        "Anybody else got a problem with Webistics?" -- Sopranos 24:17



More information about the talk mailing list