|
In PHP, and error in the parsing of the PHP script will cause
an error, and the parser will abort. If you want to handle
the error, it is a good idea to add an error handling routing.
This is set using the set_error_handler() function, as shown
next.
|
PHP
|
Executed Code
|
| Generating an error: |
<?php
set_error_handler("CustomErrorHandler");
?>
<?php
$val=1/0; // divide-by-zero error
?>
|
An error has occurredError number: 2Description: Division by zeroScript name: E:\kunden\homepages\29\d390184582\www\php_error.phpLine number: 128
|
| Error handling function: |
<?php
function CustomErrorHandler($errNumber, $errDescription, $errFile, $errLine)
{
print "<H2>An error has occurred";
print "<P>Error number: $errNumber";
print "<P>Description: $errDescription";
print "<P>Script name: $errFile";
print "<P>Line number: $errLine";
}
?>
|
|
|