<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Error Control Operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="Operators" HREF="language.operators.html"><LINK REL="PREVIOUS" TITLE="Comparison Operators" HREF="language.operators.comparison.html"><LINK REL="NEXT" TITLE="Execution Operators" HREF="language.operators.execution.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-2"></HEAD ><BODY CLASS="sect1" 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 PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="language.operators.comparison.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Cap. 10. Operators</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.operators.execution.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.operators.errorcontrol" >Error Control Operators</A ></H1 ><P > PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. </P ><P > If the <A HREF="missing-stuff.html#ini.track-errors" ><VAR CLASS="option" >track_errors</VAR ></A > feature is enabled, any error message generated by the expression will be saved in the variable <A HREF="reserved.variables.html#reserved.variables.phperrormsg" >$php_errormsg</A >. This variable will be overwritten on each error, so check early if you want to use it. </P ><P > <DIV CLASS="informalexample" ><P ></P ><A NAME="AEN2154" ></A ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">/* Intentional file error */<br /></font><font color="#0000BB">$my_file </font><font color="#007700">= @</font><font color="#0000BB">file </font><font color="#007700">(</font><font color="#DD0000">'non_existent_file'</font><font color="#007700">) or<br /> die (</font><font color="#DD0000">"Failed opening file: error was '$php_errormsg'"</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// this works for any expression, not just functions:<br /></font><font color="#0000BB">$value </font><font color="#007700">= @</font><font color="#0000BB">$cache</font><font color="#007700">[</font><font color="#0000BB">$key</font><font color="#007700">]; <br /></font><font color="#FF8000">// will not issue a notice if the index $key doesn't exist.<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P ></P ></DIV > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > The @-operator works only on <A HREF="language.expressions.html" >expressions</A >. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. For instance, you can prepend it to variables, function and <A HREF="function.include.html" ><B CLASS="function" >include()</B ></A > calls, constants, and so forth. You cannot prepend it to function or class definitions, or conditional structures such as <VAR CLASS="literal" >if</VAR > and <VAR CLASS="literal" >foreach</VAR >, and so forth. </P ></BLOCKQUOTE ></DIV ><P > See also <A HREF="function.error-reporting.html" ><B CLASS="function" >error_reporting()</B ></A > and the manual section for <A HREF="ref.errorfunc.html" >Error Handling and Logging functions</A >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > The "@" error-control operator prefix will not disable messages that are the result of parse errors. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Avertisment</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why. </P ></TD ></TR ></TABLE ></DIV ></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="language.operators.comparison.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.operators.execution.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Comparison Operators</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="language.operators.html" ACCESSKEY="U" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Execution Operators</TD ></TR ></TABLE ></DIV ></BODY ></HTML >