2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-04-05 10:51:53 +00:00
|
|
|
<!-- $Revision: 1.8 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/errorfunc.xml, last change in rev 1.1 -->
|
|
|
|
<refentry id="function.restore-error-handler">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>restore_error_handler</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Restores the previous error handler function
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
2004-11-01 16:40:58 +00:00
|
|
|
&reftitle.description;
|
2002-04-15 00:12:54 +00:00
|
|
|
<methodsynopsis>
|
2004-12-14 11:53:48 +00:00
|
|
|
<type>bool</type><methodname>restore_error_handler</methodname>
|
2002-04-15 00:12:54 +00:00
|
|
|
<void/>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Used after changing the error handler function using
|
|
|
|
<function>set_error_handler</function>, to revert to the previous error
|
2004-12-14 11:53:48 +00:00
|
|
|
handler (which could be the built-in or a user defined function). This
|
|
|
|
function always returns &true;.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>error_reporting</function>,
|
|
|
|
<function>set_error_handler</function>,
|
2004-12-14 11:53:48 +00:00
|
|
|
<function>restore_exception_handler</function>,
|
2003-12-01 11:46:50 +00:00
|
|
|
<function>trigger_error</function>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
2005-04-04 18:00:21 +00:00
|
|
|
<para>
|
|
|
|
The example below shows the handling of internal exceptions by
|
|
|
|
triggering errors and handling them with a user defined function. It then
|
|
|
|
restores the original PHP error handling:
|
|
|
|
<example>
|
|
|
|
<title>
|
|
|
|
Error handling with <function>set_error_handler</function>,
|
|
|
|
<function>trigger_error</function> and
|
|
|
|
<function>restore_error_handler</function>
|
|
|
|
</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
// set the error reporting level for this script
|
2005-04-05 07:16:48 +00:00
|
|
|
error_reporting(E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);
|
2005-04-04 18:00:21 +00:00
|
|
|
|
|
|
|
// error handler function
|
|
|
|
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
|
|
|
{
|
2005-04-05 07:16:48 +00:00
|
|
|
switch ($errno) {
|
|
|
|
case E_USER_ERROR:
|
2005-04-05 10:51:53 +00:00
|
|
|
echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
|
2005-04-05 07:16:48 +00:00
|
|
|
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:
|
2005-04-05 10:51:53 +00:00
|
|
|
echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
|
2005-04-05 07:16:48 +00:00
|
|
|
break;
|
|
|
|
case E_USER_NOTICE:
|
2005-04-05 10:51:53 +00:00
|
|
|
echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
|
2005-04-05 07:16:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
echo "My unkown error type: [$errno] $errstr<br />\n";
|
|
|
|
break;
|
|
|
|
}
|
2005-04-04 18:00:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_error_handler("myErrorHandler");
|
2005-04-05 07:16:48 +00:00
|
|
|
trigger_error('Test error', E_USER_WARNING);
|
2005-04-04 18:00:21 +00:00
|
|
|
|
|
|
|
restore_error_handler(); // Will restore standard PHP handler
|
2005-04-05 07:16:48 +00:00
|
|
|
trigger_error('Test error', E_USER_WARNING);
|
2005-04-04 18:00:21 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
&example.outputs.similar;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
My ERROR [512] Test error
|
|
|
|
|
|
|
|
Warning: Test error in C:\Program Files\Apache Group\Apache2\htdocs\readdir.php on line 45
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
2002-04-15 00:12:54 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|