Remove confusing constants, fix WS

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@183636 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2005-04-05 07:16:48 +00:00
parent 2c48aaf9a9
commit 85caf84cd8

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/errorfunc.xml, last change in rev 1.1 -->
<refentry id="function.restore-error-handler">
<refnamediv>
@ -39,42 +39,37 @@
<programlisting role="php">
<![CDATA[
<?php
// redefine the user error constants - PHP 4 only
define("FATAL", E_USER_ERROR);
define("ERROR", E_USER_WARNING);
define("WARNING", E_USER_NOTICE);
// set the error reporting level for this script
error_reporting(FATAL | ERROR | WARNING);
error_reporting(E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case FATAL:
echo "<b>My FATAL</b> [$errno] $errstr<br />\n";
echo " Fatal error in line $errline of file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
echo "Aborting...<br />\n";
exit(1);
break;
case ERROR:
echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
break;
case WARNING:
echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
default:
echo "My unkown error type: [$errno] $errstr<br />\n";
break;
}
switch ($errno) {
case E_USER_ERROR:
echo "<b>My FATAL</b> [$errno] $errstr<br />\n";
echo " Fatal error in line $errline of file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
echo "Aborting...<br />\n";
exit(1);
break;
case E_USER_WARNING:
echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
break;
case E_USER_NOTICE:
echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
default:
echo "My unkown error type: [$errno] $errstr<br />\n";
break;
}
}
set_error_handler("myErrorHandler");
trigger_error('Test error', ERROR);
trigger_error('Test error', E_USER_WARNING);
restore_error_handler(); // Will restore standard PHP handler
trigger_error('Test error', ERROR);
trigger_error('Test error', E_USER_WARNING);
?>
]]>
</programlisting>