Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9383

php-manual-en-7.2.11-1.mga7.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>Basics</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.errors.html">Errors</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.errors.php7.html">Errors in PHP 7</a></div>
 <div class="up"><a href="language.errors.html">Errors</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="language.errors.basics" class="sect1">
 <h2 class="title">Basics</h2>

 <p class="para">
  PHP reports errors in response to a number of internal error conditions.
  These may be used to signal a number of different conditions, and can be
  displayed and/or logged as required.
 </p>

 <p class="para">
  Every error that PHP generates includes a type. A
  <a href="errorfunc.constants.html" class="link">list of these types</a> is available,
  along with a short description of their behaviour and how they can be
  caused.
 </p>

 <div class="sect2" id="language.errors.basics.handling">
  <h3 class="title">Handling errors with PHP</h3>

  <p class="para">
   If no error handler is set, then PHP will handle any errors that occur
   according to its configuration. Which errors are reported and which are
   ignored is controlled by the
   <a href="errorfunc.configuration.html#ini.error-reporting" class="link"><code class="parameter">error_reporting</code></a>
   php.ini directive, or at runtime by calling
   <span class="function"><a href="function.error-reporting.html" class="function">error_reporting()</a></span>. It is strongly recommended that the
   configuration directive be set, however, as some errors can occur before
   execution of your script begins.
  </p>

  <p class="para">
   In a development environment, you should always set
   <a href="errorfunc.configuration.html#ini.error-reporting" class="link"><code class="parameter">error_reporting</code></a>
   to <strong><code>E_ALL</code></strong>, as you need to be aware of and fix the
   issues raised by PHP. In production, you may wish to set this to a less
   verbose level such as
   <code class="code">E_ALL &amp; ~E_NOTICE &amp; ~E_STRICT &amp; ~E_DEPRECATED</code>, but
   in many cases <strong><code>E_ALL</code></strong> is also appropriate, as it may
   provide early warning of potential issues.
  </p>

  <p class="para">
   What PHP does with these errors depends on two further php.ini directives.
   <a href="errorfunc.configuration.html#ini.display-errors" class="link"><code class="parameter">display_errors</code></a>
   controls whether the error is shown as part of the script&#039;s output. This
   should always be disabled in a production environment, as it can include
   confidential information such as database passwords, but is often useful to
   enable in development, as it ensures immediate reporting of issues.
  </p>

  <p class="para">
   In addition to displaying errors, PHP can log errors when the
   <a href="errorfunc.configuration.html#ini.log-errors" class="link"><code class="parameter">log_errors</code></a>
   directive is enabled. This will log any errors to the file or syslog
   defined by
   <a href="errorfunc.configuration.html#ini.error-log" class="link"><code class="parameter">error_log</code></a>. This
   can be extremely useful in a production environment, as you can log errors
   that occur and then generate reports based on those errors.
  </p>
 </div>

 <div class="sect2" id="language.errors.basics.user">
  <h3 class="title">User error handlers</h3>

  <p class="para">
   If PHP&#039;s default error handling is inadequate, you can also handle many
   types of error with your own custom error handler by installing it with
   <span class="function"><a href="function.set-error-handler.html" class="function">set_error_handler()</a></span>. While some error types cannot be
   handled this way, those that can be handled can then be handled in the way
   that your script sees fit: for example, this can be used to show a custom
   error page to the user and then report more directly than via a log, such
   as by sending an e-mail.
  </p>
 </div>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.errors.html">Errors</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.errors.php7.html">Errors in PHP 7</a></div>
 <div class="up"><a href="language.errors.html">Errors</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>