PHP: Error Handling and Logging Functions - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<dotnet_loaddebug_backtrace>
view the version of this page
Last updated: Wed, 29 Jan 2003

XXVII. Error Handling and Logging Functions

These are functions dealing with error handling and logging. They allow you to define your own error handling rules, as well as modify the way the errors can be logged. This allows you to change and enhance error reporting to suit your needs.

With the logging functions, you can send messages directly to other machines, to an email (or email to pager gateway!), to system logs, etc., so you can selectively log and monitor the most important parts of your applications and websites.

The error reporting functions allow you to customize what level and kind of error feedback is given, ranging from simple notices to customized functions returned during errors.

차례
debug_backtrace --  Generates a backtrace
error_log -- send an error message somewhere
error_reporting -- set which PHP errors are reported
restore_error_handler --  Restores the previous error handler function
set_error_handler --  Sets a user-defined error handler function.
trigger_error --  Generates a user-level error/warning/notice message
user_error --  Generates a user-level error/warning/notice message


User Contributed Notes
Error Handling and Logging Functions
add a note add a note
pgerzsonr at freestart dot hu
11-Jan-2002 03:03

A handy errorhandler class can be found at:



It has several enhancements (report layouts):

* prints the source code fragment where the error encountered,
* prints variable context around error source,
* suppresses error-messages, instead displays an arbitrary HTML or PHP page
* logging to multiple targets and autodetecting target logging
* error messages can be displayed in a separate browser window
* catching errors for runtime generated codes
* debugging variables.

webmaster at zdarmanet dot net
26-Jan-2003 05:48

I use something like this (and of course all necessary stuff like set_error_handler):

function myHandler(...) {
 include(...) // the code loaded in case of error
}

Then one of my scripts stops execution after the second pass throw a line like:

list(...)=mysql_fetch_row(...)

The solution is the following: myHandler must return something in case of error number 8 (Notice), i.e.

 return 0;

What value it returns is not significant: I tested it with true and false and it works in all cases.

The strangest is that when I include the function code of myHandler staticaly (not via a conditional include), it works without the return statement!

The PHP construct list or the function mysql_fetch_row might use this error number for other usage than error reporting and it's a pitty that these details are not listed here in the manual. Not to say it was very hard to find out where the problem was because the problem was inside an error handler and PHP does not allow recursive call to an error handler.

add a note add a note

<dotnet_loaddebug_backtrace>
 Last updated: Wed, 29 Jan 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Thu May 22 21:11:29 2003 CEST