<HTML ><HEAD ><TITLE >Error Control Operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" 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-1"></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" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="language.operators.comparison.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 11. Operators</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.operators.execution.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.operators.errorcontrol" ></A >Error Control Operators</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="ref.errorfunc.html#ini.track-errors" >track_errors</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" ><A NAME="AEN4628" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php /* Intentional file error */ $my_file = @file ('non_existent_file') or die ("Failed opening file: error was '$php_errormsg'"); // this works for any expression, not just functions: $value = @$cache[$key]; // will not issue a notice if the index $key doesn't exist. ?></PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </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 <TT CLASS="literal" >if</TT > and <TT CLASS="literal" >foreach</TT >, and so forth. </P ></BLOCKQUOTE ></DIV ><P > See also <A HREF="function.error-reporting.html" ><B CLASS="function" >error_reporting()</B ></A >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </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 >Warning</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" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.operators.execution.html" ACCESSKEY="N" >Next</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" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Execution Operators</TD ></TR ></TABLE ></DIV ></BODY ></HTML >