<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >trigger_error</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Erros e Logs" HREF="ref.errorfunc.html"><LINK REL="PREVIOUS" TITLE="set_exception_handler" HREF="function.set-exception-handler.html"><LINK REL="NEXT" TITLE="user_error" HREF="function.user-error.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.set-exception-handler.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.user-error.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.trigger-error" ></A >trigger_error</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN44358" ></A ><P > (PHP 4 >= 4.0.1, PHP 5)</P >trigger_error -- Gera uma mensagem de usuário sobre error/warning/notice </DIV ><DIV CLASS="refsect1" ><A NAME="AEN44361" ></A ><H2 >Descrição</H2 >void <B CLASS="methodname" >trigger_error</B > ( string error_msg [, int error_type] )<BR ></BR ><P > Usa para realizar uma condição de erro, pode ser usado em conjunto com o gerenciador de erros padrão ou com uma função definida pelo usuário, se for definida como gerenciador de erros com <A HREF="function.set-error-handler.html" ><B CLASS="function" >set_error_handler()</B ></A >. Somente funciona com as constantes da família E_USER, e o padrão é <TT CLASS="constant" ><B >E_USER_NOTICE</B ></TT >. </P ><P > Esta função é útil quando você quer gerar uma resposta para uma exceção durante a execução do script. Por exemplo: <DIV CLASS="informalexample" ><P ></P ><A NAME="AEN44376" ></A ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">if (</font><font color="#0000BB">assert</font><font color="#007700">(</font><font color="#0000BB">$divisor </font><font color="#007700">== </font><font color="#0000BB">0</font><font color="#007700">)) {<br /> </font><font color="#0000BB">trigger_error</font><font color="#007700">(</font><font color="#DD0000">"Não posso dividir por zero"</font><font color="#007700">, </font><font color="#0000BB">E_USER_ERROR</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P ></P ></DIV > <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Veja <A HREF="function.set-error-handler.html" ><B CLASS="function" >set_error_handler()</B ></A > para um exemplo maior. </P ></BLOCKQUOTE ></DIV > <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > <CODE CLASS="parameter" >error_msg</CODE > é limitado a 1024 caracteres de tamanho. Qualquer caractere adicional além de 1024 serão truncados. </P ></BLOCKQUOTE ></DIV > </P ><P > Veja também <A HREF="function.error-reporting.html" ><B CLASS="function" >error_reporting()</B ></A >, <A HREF="function.set-error-handler.html" ><B CLASS="function" >set_error_handler()</B ></A >, <A HREF="function.restore-error-handler.html" ><B CLASS="function" >restore_error_handler()</B ></A > e <A HREF="ref.errorfunc.html#errorfunc.constants" >constantes de níveis de erro</A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.set-exception-handler.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.user-error.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >set_exception_handler</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.errorfunc.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >user_error</TD ></TR ></TABLE ></DIV ></BODY ></HTML >