Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 8941

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Error Control Operators</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.operators.comparison.html">Comparison Operators</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.operators.execution.html">Execution Operators</a></div>
 <div class="up"><a href="language.operators.html">Operators</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="language.operators.errorcontrol" class="sect1">
   <h2 class="title">Error Control Operators</h2>
   <p class="simpara">
    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 class="simpara">
    If you have set a custom error handler function with
     <span class="function"><a href="function.set-error-handler.html" class="function">set_error_handler()</a></span> then it will still get
    called, but this custom error handler can (and should) call  <span class="function"><a href="function.error-reporting.html" class="function">error_reporting()</a></span>
    which will return 0 when the call that triggered the error was preceded by an @.
   </p>
   <p class="simpara">
    If the <a href="errorfunc.configuration.html#ini.track-errors" class="link"><strong class="option unknown">track_errors</strong>
</a>
    feature is enabled, any error message generated by the expression
    will be saved in the variable
    <var class="varname"><var class="varname"><a href="reserved.variables.phperrormsg.html" class="classname">$php_errormsg</a></var></var>.
    This variable will be overwritten on each error, so check early if you
    want to use it.
   </p>
   <p class="para">
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Intentional&nbsp;file&nbsp;error&nbsp;*/<br /></span><span style="color: #0000BB">$my_file&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">file&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">'non_existent_file'</span><span style="color: #007700">)&nbsp;or<br />&nbsp;&nbsp;&nbsp;&nbsp;die&nbsp;(</span><span style="color: #DD0000">"Failed&nbsp;opening&nbsp;file:&nbsp;error&nbsp;was&nbsp;'</span><span style="color: #0000BB">$php_errormsg</span><span style="color: #DD0000">'"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;this&nbsp;works&nbsp;for&nbsp;any&nbsp;expression,&nbsp;not&nbsp;just&nbsp;functions:<br /></span><span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">$cache</span><span style="color: #007700">[</span><span style="color: #0000BB">$key</span><span style="color: #007700">];<br /></span><span style="color: #FF8000">//&nbsp;will&nbsp;not&nbsp;issue&nbsp;a&nbsp;notice&nbsp;if&nbsp;the&nbsp;index&nbsp;$key&nbsp;doesn't&nbsp;exist.<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="simpara">
     The @-operator works only on
     <a href="language.expressions.html" class="link">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  <span class="function"><a href="function.include.html" class="function">include</a></span> calls, constants, and
     so forth. You cannot prepend it to function or class definitions,
     or conditional structures such as <em>if</em> and
     <a href="control-structures.foreach.html" class="link">foreach</a>, and so forth.
    </span>
   </p></blockquote>
   <p class="simpara">
    See also  <span class="function"><a href="function.error-reporting.html" class="function">error_reporting()</a></span> and the manual section for
    <a href="ref.errorfunc.html" class="link">Error Handling and Logging functions</a>.
   </p>
   <div class="warning"><strong class="warning">Warning</strong>
    <p class="para">
     Currently the &quot;@&quot; 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 &quot;@&quot; to
     suppress errors from a certain function and either it isn&#039;t
     available or has been mistyped, the script will die right there
     with no indication as to why.
    </p>
   </div>
  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.operators.comparison.html">Comparison Operators</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.operators.execution.html">Execution Operators</a></div>
 <div class="up"><a href="language.operators.html">Operators</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>