<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.3 $ --> <refentry id="function.set-exception-handler"> <refnamediv> <refname>set_exception_handler</refname> <refpurpose> Sets a user-defined exception handler function </refpurpose> </refnamediv> <refsect1> &reftitle.description; <methodsynopsis> <type>string</type><methodname>set_exception_handler</methodname> <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> <para> The <parameter>exception_handler</parameter> must be defined before calling <function>set_exception_handler</function>. This function needs to accept one parameter, which will be the exception object that was thrown. <methodsynopsis> <methodname><replaceable>exception_handler</replaceable></methodname> <methodparam><type>object</type><parameter>exception</parameter></methodparam> </methodsynopsis> <variablelist> <varlistentry> <term><parameter>exception</parameter></term> <listitem> <para> Name of function to be called when an uncaught exception occurs. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>exception_handler</parameter></term> <listitem> <para> Name of function to be called when an uncaught exception occurs. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1> &reftitle.returnvalues; <para> Returns the previously defined exception handler, or &false; on error. If no previous handler was defined, an empty string is returned. </para> </refsect1> <refsect1> &reftitle.examples; <para> <example> <title><function>set_exception_handler</function> example</title> <programlisting role="php"> <![CDATA[ <?php function exception_handler($exception) { echo "Uncaught exception: " , $exception->getMessage(), "\n"; } set_exception_handler('exception_handler'); throw new Exception('Uncaught Exception'); echo "Not Executed\n"; ]]> </programlisting> </example> </para> </refsect1> <refsect1> &reftitle.seealso; <para> <function>restore_exception_handler</function> <function>restore_error_handler</function> <function>error_reporting</function>&listendand; <link linkend="language.oop5.exceptions">PHP 5 Exceptions</link> </para> </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 -->