<?php
// set this to false if you don't want error messages output to the user.
$debug true;

// Create the error handler.
function my_error_handler ($e_number$e_message$e_file$e_line$e_vars) {
    
    global 
$debug;
    
    
// This line prevents the error suppression operator --- @ --- from generating error reports
    
if (error_reporting() == 0) { return; }
    
    
// Build the error message.
    
$message "An error occured in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";
    
    
// Add the date and time.
    
$message .= "Date/Time: " date('n-j-Y H:i:s') . "\n<br />";
    
    
// Append $e_vars to the message.
    
$message .= "<pre>" print_r ($e_vars1) . "</pre>\n<br />";
    
    if (
$debug) { // Show the error.
        
echo '<div align="left"><p class="error">' $message '</p></div>';
    } else {
        
        
// Log the error:
        // You could write the error to a file, very useful on a live site, or shoot them off in an email.
        
    
// End of debug IF
    
// End of my_error_handler() definition.

// Use my error handler:
set_error_handler('my_error_handler');