&reftitle.examples; Below we can see an example of using the error handling capabilities in PHP. We define an error handling function which logs the information into a file (using an XML format), and e-mails the developer in case a critical error in the logic happens. Using error handling in a script 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error' ); // set of errors for which a var trace will be saved $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); $err = "\n"; $err .= "\t" . $dt . "\n"; $err .= "\t" . $errno . "\n"; $err .= "\t" . $errortype[$errno] . "\n"; $err .= "\t" . $errmsg . "\n"; $err .= "\t" . $filename . "\n"; $err .= "\t" . $linenum . "\n"; if (in_array($errno, $user_errors)) { $err .= "\t" . wddx_serialize_value($vars, "Variables") . "\n"; } $err .= "\n\n"; // for testing // echo $err; // save to the error log, and e-mail me if there is a critical user error error_log($err, 3, "/usr/local/php4/error.log"); if ($errno == E_USER_ERROR) { mail("phpdev@example.com", "Critical User Error", $err); } } function distance($vect1, $vect2) { if (!is_array($vect1) || !is_array($vect2)) { trigger_error("Incorrect parameters, arrays expected", E_USER_ERROR); return NULL; } if (count($vect1) != count($vect2)) { trigger_error("Vectors need to be of the same size", E_USER_ERROR); return NULL; } for ($i=0; $i ]]>