2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2003-12-15 16:55:22 +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.trigger-error">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>trigger_error</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Generates a user-level error/warning/notice message
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>void</type><methodname>trigger_error</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>error_msg</parameter></methodparam>
|
|
|
|
<methodparam choice="opt"><type>int</type><parameter>error_type</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Used to trigger a user error condition, it can be used by in conjunction
|
|
|
|
with the built-in error handler, or with a user defined function that has
|
|
|
|
been set as the new error handler
|
|
|
|
(<function>set_error_handler</function>). It only works with the E_USER
|
|
|
|
family of constants, and will default to <constant>E_USER_NOTICE</constant>.
|
|
|
|
</para>
|
|
|
|
<para>
|
2003-05-05 17:38:24 +00:00
|
|
|
This function is useful when
|
2002-04-15 00:12:54 +00:00
|
|
|
you need to generate a particular response to an exception at runtime.
|
|
|
|
For example:
|
|
|
|
<informalexample>
|
2003-08-16 18:59:12 +00:00
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-08-16 18:59:12 +00:00
|
|
|
<?php
|
2003-12-15 16:55:22 +00:00
|
|
|
if (assert($divisor == 0)) {
|
|
|
|
trigger_error("Cannot divide by zero", E_USER_ERROR);
|
2003-05-05 17:38:24 +00:00
|
|
|
}
|
2003-08-16 18:59:12 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
<note>
|
2003-01-20 20:46:25 +00:00
|
|
|
<para>
|
|
|
|
See <function>set_error_handler</function> for a more extensive example.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<parameter>error_msg</parameter> is limited to 1024 characters in length.
|
|
|
|
Any additional characters beyond 1024 will be truncated.
|
|
|
|
</para>
|
2002-04-15 00:12:54 +00:00
|
|
|
</note>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>error_reporting</function>,
|
|
|
|
<function>set_error_handler</function>,
|
2003-06-09 19:30:56 +00:00
|
|
|
<function>restore_error_handler</function>, and
|
2003-12-01 11:46:50 +00:00
|
|
|
<link linkend="errorfunc.constants">error level constants</link>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</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
|
|
|
|
-->
|