2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:57:16 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.set-exception-handler" xmlns="http://docbook.org/ns/docbook">
|
2004-08-26 02:28:16 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>set_exception_handler</refname>
|
2004-08-26 05:37:58 +00:00
|
|
|
<refpurpose>
|
|
|
|
Sets a user-defined exception handler function
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2007-02-04 22:49:08 +00:00
|
|
|
|
2007-01-16 01:24:43 +00:00
|
|
|
<refsect1 role="description">
|
2004-08-26 02:28:16 +00:00
|
|
|
&reftitle.description;
|
|
|
|
<methodsynopsis>
|
2009-09-08 10:43:44 +00:00
|
|
|
<type>callback</type><methodname>set_exception_handler</methodname>
|
2004-08-26 02:28:16 +00:00
|
|
|
<methodparam><type>callback</type><parameter>exception_handler</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Sets the default exception handler if an exception is not caught within a
|
|
|
|
try/catch block. Execution will stop after the
|
|
|
|
<parameter>exception_handler</parameter> is called.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-02-04 22:49:08 +00:00
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
2004-08-26 02:28:16 +00:00
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
2004-08-26 05:37:58 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>exception_handler</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-02-04 22:49:08 +00:00
|
|
|
Name of the function to be called when an uncaught exception occurs.
|
|
|
|
This function must be defined before calling
|
|
|
|
<function>set_exception_handler</function>. This handler function
|
|
|
|
needs to accept one parameter, which will be the exception object that
|
|
|
|
was thrown.
|
2004-08-26 05:37:58 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2004-08-26 02:28:16 +00:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-02-04 22:49:08 +00:00
|
|
|
|
2007-01-16 01:24:43 +00:00
|
|
|
<refsect1 role="returnvalues">
|
2004-08-26 02:28:16 +00:00
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2005-11-04 14:12:16 +00:00
|
|
|
Returns the name of the previously defined exception handler, or &null; on error. If
|
|
|
|
no previous handler was defined, &null; is also returned.
|
2004-08-26 02:28:16 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-02-04 22:49:08 +00:00
|
|
|
|
2007-01-16 01:24:43 +00:00
|
|
|
<refsect1 role="examples">
|
2004-08-26 02:28:16 +00:00
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
2004-08-26 05:37:58 +00:00
|
|
|
<title><function>set_exception_handler</function> example</title>
|
2004-08-26 02:28:16 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
function exception_handler($exception) {
|
2004-08-26 05:37:58 +00:00
|
|
|
echo "Uncaught exception: " , $exception->getMessage(), "\n";
|
2004-08-26 02:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_exception_handler('exception_handler');
|
|
|
|
|
|
|
|
throw new Exception('Uncaught Exception');
|
|
|
|
echo "Not Executed\n";
|
2004-11-08 12:10:21 +00:00
|
|
|
?>
|
2004-08-26 02:28:16 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-02-04 22:49:08 +00:00
|
|
|
|
2008-11-15 18:34:55 +00:00
|
|
|
<refsect1 role="seealso"><!-- {{{ -->
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
|
|
|
<member><function>restore_exception_handler</function></member>
|
|
|
|
<member><function>restore_error_handler</function></member>
|
|
|
|
<member><function>error_reporting</function></member>
|
|
|
|
<member>&seealso.callback;</member>
|
|
|
|
<member><link linkend="language.exceptions">PHP 5 Exceptions</link></member>
|
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
</refsect1><!-- }}} -->
|
|
|
|
|
2004-08-26 02:28:16 +00:00
|
|
|
</refentry>
|
2004-07-24 06:35:11 +00:00
|
|
|
|
|
|
|
<!-- 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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2004-07-24 06:35:11 +00:00
|
|
|
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
|
|
|
|
-->
|