Name
error_reporting
Synopsis
int error_reporting([int level
])
Sets the level of errors reported by PHP to
level
and returns the current level; if
level
is omitted, the current level of
error reporting is returned. The following values are available for
the function:
| Runtime warnings |
| Runtime warnings |
| Compile-time parse errors |
| Runtime notices |
| Errors generated internally by PHP |
| Warnings generated internally by PHP |
| Errors generated internally by the Zend scripting engine |
| Warnings generated internally by the Zend scripting engine |
| Runtime errors generated by a call
to |
| Runtime warnings generated by a
call to |
| All of the above options |
Any number of these options can be ORed (bit-wise OR, “|”) together, so that errors in each of the levels are reported. For example, the following code turns off user errors and warnings, performs some actions, then restores the original level:
<?php $level = error_reporting( ); error_reporting($level & ~(E_USER_ERROR | E_USER_WARNING)); // do some stuff error_reporting($level); ?>
Get Programming PHP, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.