<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.errors.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'language.errors.basics.php',
    1 => 'Basics',
    2 => 'Basics',
  ),
  'up' => 
  array (
    0 => 'language.errors.php',
    1 => 'Errors',
  ),
  'prev' => 
  array (
    0 => 'language.errors.php',
    1 => 'Errors',
  ),
  'next' => 
  array (
    0 => 'language.errors.php7.php',
    1 => 'Errors in PHP 7',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'language/errors/basics.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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.php" class="link">list of these error 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.php#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.php" 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.php#ini.error-reporting" class="link"><code class="parameter">error_reporting</code></a>
   to <strong><code><a href="errorfunc.constants.php#constant.e-all">E_ALL</a></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_DEPRECATED</code>, but
   in many cases <strong><code><a href="errorfunc.constants.php#constant.e-all">E_ALL</a></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.php#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.php#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.php#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.php" 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><?php manual_footer($setup); ?>