PHP error_reporting method
The error_reporting() function in php sets the error_reporting directive at runtime. When you set error_reporting in script, it sets temporary error reporting while running script.
Syntax:
error_reporting(level);
level optional integer or predefined constants with pipe sign. Here is example below:
<?php
// disable all error reporting
error_reporting(0);
// simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);
// all PHP errors
error_reporting(E_ALL);
// all PHP errors
error_reporting(-1);
// as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
Predefined constants
Value | Constant | Description |
---|---|---|
1 | E_ERROR | Fatal run-time errors. Script execution will stop. |
2 | E_WARNING | Fatal run-time errors. |
4 | E_PARSE | Compile-time parse errors. |
8 | E_NOTICE | Run time warninigs with notice. |
16 | E_CORE_ERROR | Warnings during PHP's initial starting. |
32 | E_CORE_WARNING | Warnings during PHP's initial starting. |
64 | E_COMPILE_ERROR | Fatal compile-time errors. |
128 | E_COMPILE_WARNING | Compile-time warnings. |
256 | E_USER_ERROR | User-generated error message. |
512 | E_USER_WARNING | User-generated warning message. |
1024 | E_USER_NOTICE | User-generated notice message. |
2048 | E_STRICT | Suggestion to improve forward compatibility of your code. |
4096 | E_RECOVERABLE_ERROR | Catchable fatal error. |
8192 | E_DEPRECATED | Run-time notices that will not work in future versions. |
16384 | E_USER_DEPRECATED | User-generated warning message. |
32767 | E_ALL | All errors and warnings except E_STRICT |
We hope you like this small article and it will be help you a lot.
Copyright 2023 HackTheStuff