2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2008-11-13 19:35:40 +00:00
|
|
|
<!-- $Revision: 1.23 $ -->
|
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
|
|
|
|
your script.
|
|
|
|
</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>
|
|
|
|
The available error level constants are listed below. The actual
|
|
|
|
meanings of these error levels are described in the
|
|
|
|
<link linkend="errorfunc.constants">predefined constants</link>.
|
|
|
|
<table>
|
|
|
|
<title><function>error_reporting</function> level constants and bit values</title>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>value</entry>
|
|
|
|
<entry>constant</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>1</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-error">E_ERROR</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>2</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-warning">E_WARNING</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>4</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-parse">E_PARSE</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>8</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-notice">E_NOTICE</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>16</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-core-error">E_CORE_ERROR</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>32</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-core-warning">E_CORE_WARNING</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>64</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-compile-error">E_COMPILE_ERROR</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>128</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-compile-warning">E_COMPILE_WARNING</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>256</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-user-error">E_USER_ERROR</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>512</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-user-warning">E_USER_WARNING</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>1024</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-user-error">E_USER_NOTICE</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2007-01-26 10:24:53 +00:00
|
|
|
<entry>6143</entry>
|
2005-04-24 23:19:35 +00:00
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-all">E_ALL</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
2008-07-21 12:11:11 +00:00
|
|
|
</row>
|
2005-04-24 23:19:35 +00:00
|
|
|
<row>
|
|
|
|
<entry>2048</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-strict">E_STRICT</link>
|
2005-04-24 23:19:35 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
2006-06-08 11:19:12 +00:00
|
|
|
<row>
|
|
|
|
<entry>4096</entry>
|
|
|
|
<entry>
|
2007-06-16 21:08:14 +00:00
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-recoverable-error">E_RECOVERABLE_ERROR</link>
|
2006-06-08 11:19:12 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
2008-07-21 12:11:11 +00:00
|
|
|
<row>
|
|
|
|
<entry>8192</entry>
|
|
|
|
<entry>
|
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-deprecated-error">E_DEPRECATED</link>
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>16384</entry>
|
|
|
|
<entry>
|
|
|
|
<link linkend="errorfunc.constants.errorlevels.e-user-deprecated">E_USER_DEPRECATED</link>
|
|
|
|
</entry>
|
|
|
|
</row>
|
2005-04-24 23:19:35 +00:00
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
|
|
|
</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>
|
|
|
|
level.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2007-01-26 10:24:53 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>5.0.0</entry>
|
|
|
|
<entry><constant>E_STRICT</constant> introduced (not part of <constant>E_ALL</constant>).</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>5.2.0</entry>
|
|
|
|
<entry><constant>E_RECOVERABLE_ERROR</constant> introduced.</entry>
|
|
|
|
</row>
|
2008-08-08 09:57:14 +00:00
|
|
|
<row>
|
|
|
|
<entry>5.3.0</entry>
|
|
|
|
<entry><constant>E_DEPRECATED</constant> and <constant>E_USER_DEPRECATED</constant> introduced.</entry>
|
|
|
|
</row>
|
2007-01-26 10:24:53 +00:00
|
|
|
<row>
|
|
|
|
<entry>6</entry>
|
|
|
|
<entry><constant>E_STRICT</constant> became part of <constant>E_ALL</constant>.</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2005-04-24 23:19:35 +00:00
|
|
|
<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
|
|
|
|
// This is the default value set in php.ini
|
2003-12-15 16:55:22 +00:00
|
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2008-02-19 21:45:32 +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
|
|
|
|
|
|
|
// 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>
|
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
|
|
|
|
sgml-default-dtd-file:"../../../../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
|
|
|
|
-->
|