mirror of
https://github.com/macintoshplus/doc-en.git
synced 2026-03-24 08:52:18 +01:00
101 lines
3.7 KiB
XML
101 lines
3.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<sect1 xml:id="language.errors.basics" xmlns="http://docbook.org/ns/docbook">
|
|
<title>Basics</title>
|
|
|
|
<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.
|
|
</para>
|
|
|
|
<para>
|
|
Every error that PHP generates includes a type. A
|
|
<link linkend="errorfunc.constants">list of these error types</link> is available,
|
|
along with a short description of their behaviour and how they can be
|
|
caused.
|
|
</para>
|
|
|
|
<sect2 xml:id="language.errors.basics.handling">
|
|
<title>Handling errors with PHP</title>
|
|
|
|
<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
|
|
<link linkend="ini.error-reporting"><parameter>error_reporting</parameter></link>
|
|
php.ini directive, or at runtime by calling
|
|
<function>error_reporting</function>. It is strongly recommended that the
|
|
configuration directive be set, however, as some errors can occur before
|
|
execution of your script begins.
|
|
</para>
|
|
|
|
<para>
|
|
In a development environment, you should always set
|
|
<link linkend="ini.error-reporting"><parameter>error_reporting</parameter></link>
|
|
to <constant>E_ALL</constant>, 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>E_ALL & ~E_NOTICE & ~E_DEPRECATED</code>, but
|
|
in many cases <constant>E_ALL</constant> is also appropriate, as it may
|
|
provide early warning of potential issues.
|
|
</para>
|
|
|
|
<para>
|
|
What PHP does with these errors depends on two further php.ini directives.
|
|
<link linkend="ini.display-errors"><parameter>display_errors</parameter></link>
|
|
controls whether the error is shown as part of the script'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.
|
|
</para>
|
|
|
|
<para>
|
|
In addition to displaying errors, PHP can log errors when the
|
|
<link linkend="ini.log-errors"><parameter>log_errors</parameter></link>
|
|
directive is enabled. This will log any errors to the file or syslog
|
|
defined by
|
|
<link linkend="ini.error-log"><parameter>error_log</parameter></link>. This
|
|
can be extremely useful in a production environment, as you can log errors
|
|
that occur and then generate reports based on those errors.
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2 xml:id="language.errors.basics.user">
|
|
<title>User error handlers</title>
|
|
|
|
<para>
|
|
If PHP's default error handling is inadequate, you can also handle many
|
|
types of error with your own custom error handler by installing it with
|
|
<function>set_error_handler</function>. 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.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|
|
|