3 The error handler provided here will feed all errors and warnings
4 into HTTP headers of the form "X-Error-NNNNN: ...", so they can't
5 disturb page output or make XML output invalid. This allows to
6 turn on complete error_reporting() without any functionality loss
7 due to premature output.
8 You of course need a good Web browser that can easily display all
9 response headers then for developing - 'w3m' makes an excellent
10 choice! (press "=" there)
13 set_error_handler("ewiki_http_header_errors");
14 ini_set("html_errors", 0);
16 function ewiki_http_header_errors($errno, $msg, $file, $line, $lvars) {
18 static $error_types = array(
19 E_PARSE => "PARSE ERROR",
21 E_WARNING => "WARNING",
24 E_USER_ERROR => "USER ERROR",
25 E_USER_WARNING => "USER WARNING",
26 E_USER_NOTICE => "USER NOTICE",
28 ($errtype = $error_types[$errno]) or ($errtype = "UNDEF ERROR");
30 #-- check for @ and disabled errors
31 $emask = get_cfg_var("error_reporting");
32 if (! ($emask & $errno)) {
37 $msg = strtr($msg, "\r\n\t\f", " ");
38 $msg = "$errtype: $msg in $file, line #$line";
40 print "\n<!--<div class=\"php-error\">$msg</div>-->\n";
44 $no = ($no & 0xFFFF) ^ ($no >> 16);
45 header("X-Error-$no: $msg");
46 if ($errno == E_FATAL) { header("Status: 500 Something bad happened"); }