2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:57:16 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.error-reporting">
|
2005-04-24 15:36:00 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>error_reporting</refname>
|
|
|
|
<refpurpose>Sets which PHP errors are reported</refpurpose>
|
|
|
|
</refnamediv>
|
2005-04-24 23:19:35 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
2005-04-24 15:36:00 +00:00
|
|
|
&reftitle.description;
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>int</type><methodname>error_reporting</methodname>
|
|
|
|
<methodparam choice="opt"><type>int</type><parameter>level</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
The <function>error_reporting</function> function sets the
|
|
|
|
<link linkend="ini.error-reporting">error_reporting</link>
|
|
|
|
directive at runtime. PHP has many levels of errors, using
|
|
|
|
this function sets that level for the duration (runtime) of
|
2009-12-22 13:33:12 +00:00
|
|
|
your script. If the optional <parameter>level</parameter> is
|
|
|
|
not set, <function>error_reporting</function> will just return
|
|
|
|
the current error reporting level.
|
2005-04-24 15:36:00 +00:00
|
|
|
</para>
|
2005-04-24 23:19:35 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
2005-04-24 15:36:00 +00:00
|
|
|
<para>
|
2005-04-24 23:19:35 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>level</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The new <link linkend="ini.error-reporting">error_reporting</link>
|
|
|
|
level. It takes on either a bitmask, or named constants. Using named
|
|
|
|
constants is strongly encouraged to ensure compatibility for future
|
|
|
|
versions. As error levels are added, the range of integers increases,
|
|
|
|
so older integer-based error levels will not always behave as expected.
|
|
|
|
</para>
|
|
|
|
<para>
|
2009-06-30 11:14:41 +00:00
|
|
|
The available error level constants and the actual
|
2005-04-24 23:19:35 +00:00
|
|
|
meanings of these error levels are described in the
|
|
|
|
<link linkend="errorfunc.constants">predefined constants</link>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2005-04-24 15:36:00 +00:00
|
|
|
</para>
|
2005-04-24 23:19:35 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
2005-04-24 15:36:00 +00:00
|
|
|
<para>
|
2005-04-24 23:19:35 +00:00
|
|
|
Returns the old <link linkend="ini.error-reporting">error_reporting</link>
|
2009-12-22 13:33:12 +00:00
|
|
|
level or the current level if no <parameter>level</parameter> parameter is
|
|
|
|
given.
|
2005-04-24 23:19:35 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
2005-04-24 15:36:00 +00:00
|
|
|
<title><function>error_reporting</function> examples</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2002-07-13 23:03:09 +00:00
|
|
|
<?php
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-07-13 23:03:09 +00:00
|
|
|
// Turn off all error reporting
|
|
|
|
error_reporting(0);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-07-13 23:03:09 +00:00
|
|
|
// Report simple running errors
|
2003-12-15 16:55:22 +00:00
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
2002-07-13 23:03:09 +00:00
|
|
|
|
2005-04-24 15:36:00 +00:00
|
|
|
// Reporting E_NOTICE can be good too (to report uninitialized
|
2002-07-13 23:03:09 +00:00
|
|
|
// variables or catch variable name misspellings ...)
|
2003-12-15 16:55:22 +00:00
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
|
2002-07-13 23:03:09 +00:00
|
|
|
|
|
|
|
// Report all errors except E_NOTICE
|
2014-04-21 19:25:14 +00:00
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2020-09-30 12:05:41 +00:00
|
|
|
// Report all PHP errors
|
2003-12-15 16:55:22 +00:00
|
|
|
error_reporting(E_ALL);
|
2002-07-13 23:03:09 +00:00
|
|
|
|
2009-04-28 17:01:07 +00:00
|
|
|
// Report all PHP errors
|
|
|
|
error_reporting(-1);
|
|
|
|
|
2002-07-13 23:03:09 +00:00
|
|
|
// Same as error_reporting(E_ALL);
|
2004-02-17 10:57:26 +00:00
|
|
|
ini_set('error_reporting', E_ALL);
|
2002-07-13 23:03:09 +00:00
|
|
|
|
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2005-04-24 15:36:00 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2005-04-24 23:19:35 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
2005-04-24 15:36:00 +00:00
|
|
|
<warning>
|
|
|
|
<simpara>
|
|
|
|
Most of <constant>E_STRICT</constant> errors are evaluated at the
|
|
|
|
compile time thus such errors are not reported in the file where
|
|
|
|
<link linkend="ini.error-reporting">error_reporting</link> is enhanced
|
2007-01-26 10:24:53 +00:00
|
|
|
to include <constant>E_STRICT</constant> errors (and vice versa).
|
2005-04-24 15:36:00 +00:00
|
|
|
</simpara>
|
|
|
|
</warning>
|
2009-04-28 17:01:07 +00:00
|
|
|
<tip>
|
|
|
|
<simpara>
|
|
|
|
Passing in the value <literal>-1</literal> will show every possible error,
|
2011-08-24 17:21:03 +00:00
|
|
|
even when new levels and constants are added in future PHP versions. The
|
|
|
|
<constant>E_ALL</constant> constant also behaves this way as of PHP 5.4.
|
2009-04-28 17:01:07 +00:00
|
|
|
</simpara>
|
|
|
|
</tip>
|
2005-04-24 23:19:35 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2005-04-24 15:36:00 +00:00
|
|
|
<para>
|
2005-04-24 23:19:35 +00:00
|
|
|
<simplelist>
|
|
|
|
<member>The <link linkend="ini.display-errors">display_errors</link> directive</member>
|
2008-11-13 19:35:40 +00:00
|
|
|
<member>The <link linkend="ini.html-errors">html_errors</link> directive</member>
|
|
|
|
<member>The <link linkend="ini.xmlrpc-errors">xmlrpc_errors</link> directive</member>
|
2005-04-24 23:19:35 +00:00
|
|
|
<member><function>ini_set</function></member>
|
|
|
|
</simplelist>
|
2005-04-24 15:36:00 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
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
|
|
|
|
-->
|