O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

E_ERROR

Fatal runtime errors (script execution halts)

E_WARNING

Runtime warnings

E_PARSE

Compile-time parse errors

E_NOTICE

Runtime notices

E_CORE_ERROR

Errors generated internally by PHP

E_CORE_WARNING

Warnings generated internally by PHP

E_COMPILE_ERROR

Errors generated internally by the Zend scripting engine

E_COMPILE_WARNING

Warnings generated internally by the Zend scripting engine

E_USER_ERROR

Runtime errors generated by a call to trigger_error()

E_USER_WARNING

Runtime warnings generated by a call to trigger_error()

E_STRICT

Direct PHP to suggest code changes to assist with forward compatibility

E_RECOVERABLE_ERROR

If a potentially fatal error has occurred, was caught, and properly handled, the code can continue execution

E_DEPRECATED

If enabled, warnings will be issued about deprecated code that will eventually not work properly

E_USER_DEPRECATED

If enabled, any warning message triggered by deprecated code can be user-generated with the trigger_error() function

E_ALL

All of the above options

Any number of these options can be ORed (bitwise 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:

<$level = error_reporting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required