php-doc-en/reference/errorfunc/functions/trigger-error.xml
Chris Wright 158026d7b2 Typo fix, remove redundant "by" in trigger_error() docs
---
Suggested by anonymous 32598

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@331617 c90b9560-bf6c-de11-be94-00142212c4b1
2013-10-01 08:10:22 +00:00

127 lines
3.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.trigger-error" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>trigger_error</refname>
<refpurpose>Generates a user-level error/warning/notice message</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>trigger_error</methodname>
<methodparam><type>string</type><parameter>error_msg</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>error_type</parameter><initializer>E_USER_NOTICE</initializer></methodparam>
</methodsynopsis>
<para>
Used to trigger a user error condition, it can be used 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>).
</para>
<para>
This function is useful when you need to generate a particular response to
an exception at runtime.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>error_msg</parameter></term>
<listitem>
<para>
The designated error message for this error. It's limited to 1024
bytes in length. Any additional characters beyond 1024 bytes will be
truncated.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>error_type</parameter></term>
<listitem>
<para>
The designated error type for this error. It only works with the E_USER
family of constants, and will default to <constant>E_USER_NOTICE</constant>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
This function returns &false; if wrong <parameter>error_type</parameter> is
specified, &true; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>trigger_error</function> example</title>
<para>
See <function>set_error_handler</function> for a more extensive example.
</para>
<programlisting role="php">
<![CDATA[
<?php
if ($divisor == 0) {
trigger_error("Cannot divide by zero", E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<warning>
<para>
HTML entities in <parameter>error_msg</parameter> are not
escaped. Use <function>htmlentities</function> on the message if
the error is to be displayed in a browser.
</para>
</warning>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>error_reporting</function></member>
<member><function>set_error_handler</function></member>
<member><function>restore_error_handler</function></member>
<member>The <link linkend="errorfunc.constants">error level constants</link></member>
</simplelist>
</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:"~/.phpdoc/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
-->