mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 16:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@177766 c90b9560-bf6c-de11-be94-00142212c4b1
78 lines
2.8 KiB
XML
78 lines
2.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- splitted from ./es/functions/errorfunc.xml, last change in rev 1.1 -->
|
|
<!-- last change to 'trigger-error' in en/ tree in rev 1.1 -->
|
|
<refentry id="function.trigger-error">
|
|
<refnamediv>
|
|
<refname>trigger_error</refname>
|
|
<refpurpose>
|
|
Genera un mensaje de error/aviso/notificación a nivel de usuario
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&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></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Esta función se utiliza generalmente para lanzar mensajes de error. Se puede usar
|
|
junto con el manejador de errores interno de PHP o con funciones manejadoras de error creadas
|
|
por el usuario (<function>set_error_handler</function>). Solamente funciona con la familia de
|
|
constantes E_USER y por defecto lo hará con <constant>E_USER_NOTICE</constant>.
|
|
</para>
|
|
<para>
|
|
El valor devuelto será &false; si se especifica un valor de <parameter>error_type</parameter> incorrecto y &true; en cualquier otro caso.
|
|
</para>
|
|
<para>
|
|
La mayor utilidad de esta función es la de generar respuestas personalizadas a las excepciones en tiempo de ejecución.
|
|
Por ejemplo:
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
if (assert($divisor == 0)) {
|
|
trigger_error("Cannot divide by zero", E_USER_ERROR);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
<note>
|
|
<para>
|
|
Puede consultar la función <function>set_error_handler</function> para ver un ejemplo m´s extenso.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
El parámetro <parameter>error_msg</parameter> tiene un límite de 1024 caracteres. La función trunca cualquier valor superior a 1024.
|
|
</para>
|
|
</note>
|
|
</para>
|
|
<para>
|
|
Puede consultar también las funciones <function>error_reporting</function>, <function>set_error_handler</function>, <function>restore_error_handler</function> y las <link linkend="errorfunc.constants"> constantes de nivel de error</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
|
|
-->
|