×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

PHP example - How to define an own error handling function for PHP to use instead of its default?


PHP - How to define an own error handling function for PHP to use instead of its default?

string set_error_handler ( string error_handler)

Example:

<?php 

function my_error_handler ($errno, $errstr, $errfile, $errline, $errcontent) 
{ 
echo "<font color='red'><b>An Error Occured!</b></font><br>"; 
echo "<b>Error Number:</b> $errno<br>"; 
echo "<b>Error Description:</b> $errstr<br>"; 
echo "<b>Error In File:</b> $errfile<br>"; 
echo "<b>Error On Line:</b> $errline<br>"; 
} 

set_error_handler("my_error_handler"); 

$x = 5/0; 

?>

Category: PHP

 
<< Go back