Location: PHPKode > projects > Communication Kit > programs/live/error_handling_inc.php
<?php
// we will do our own error handling
//error_reporting(0);

// user defined error handling function
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) {
    // timestamp for the error entry
    $dt = date("Y-m-d H:i:s (T)");

    // define an assoc array of error string
    // in reality the only entries we should
    // consider are 2,8,256,512 and 1024
    $errortype = array (
                1   =>  "Error",
                2   =>  "Warning",
                4   =>  "Parsing Error",
                8   =>  "Notice",
                16  =>  "Core Error",
                32  =>  "Core Warning",
                64  =>  "Compile Error",
                128 =>  "Compile Warning",
                256 =>  "User Error",
                512 =>  "User Warning",
                1024=>  "User Notice"
                );
    // set of errors for which a var trace will be saved
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    
    $err = "$dt ";
    $err .= $errortype[$errno];
    $err .= " ".$errmsg;
    $err .= " ".$filename;
    $err .= " Line ".$linenum;

//    if (in_array($errno, $user_errors))
//        $err .= " ".wddx_serialize_value($vars,"Variables");
    $err .= "\n";
    
    // for testing
    // echo $err;

    // save to the error log, and e-mail me if there is a critical user error
		error_log($err, 0);
//    if ($errno == E_USER_ERROR)
//        mail("hide@address.com","Critical User Error",$err);
}
// eg ways of calling this:
//     trigger_error("Incorrect parameters, arrays expected", E_USER_ERROR);
//     trigger_error("Vectors need to be of the same size", E_USER_ERROR);
//     trigger_error("Coordinate $i in vector 1 is not a number, using zero", E_USER_WARNING);
//     trigger_error("Coordinate $i in vector 2 is not a number, using zero", E_USER_WARNING);

if (!$dev){
    $old_error_handler = set_error_handler("userErrorHandler");
}
?>
Return current item: Communication Kit