downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/language.operators.errorcontrol.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/language.operators.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'language.operators.errorcontrol.php',
   
1 => 'Error Control Operators',
  ),
 
'up' =>
  array (
   
0 => 'language.operators.php',
   
1 => 'Operators',
  ),
 
'prev' =>
  array (
   
0 => 'language.operators.comparison.php',
   
1 => 'Comparison Operators',
  ),
 
'next' =>
  array (
   
0 => 'language.operators.execution.php',
   
1 => 'Execution Operators',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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 the <a href="errorfunc.configuration.php#ini.track-errors" class="link"><span class="option">track_errors</span></a>
    feature is enabled, any error message generated by the expression
    will be saved in the variable
    <var class="varname"><a href="reserved.variables.phperrormsg.php" class="classname">$php_errormsg</a></var>.
    This variable will be overwritten on each error, so check early if you
    want to use it.
   </p>
   <p class="para">
    </p><div class="informalexample">
     <div class="example-contents programlisting">
<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>
   </p>
   <blockquote><p><b class="note">Note</b>:
    <span class="simpara">
     The @-operator works only on
     <a href="language.expressions.php" 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 <a href="function.include.php" class="function">include()</a> calls, constants, and
     so forth. You cannot prepend it to function or class definitions,
     or conditional structures such as <i>if</i> and
     <a href="control-structures.foreach.php" class="link">foreach</a>, and so forth.
    </span>
   </p></blockquote>
   <p class="simpara">
    See also <a href="function.error-reporting.php" class="function">error_reporting()</a> and the manual section for
    <a href="ref.errorfunc.php" class="link">Error Handling and Logging functions</a>.
   </p>
   <div class="warning"><b class="warning">Warning</b>
    <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><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites