On PHP Error Reporting, first, you have to know about What is error reporting in PHP and how we enable it. Here is the list of the major part of error reporting in PHP which we talked about in this tutorial,
- What is PHP error reporting?
- About PHP error reporting on and off.

What is PHP Error Reporting?
Error reporting is an inbuilt feature of PHP and used to show all errors, notices, and warnings of the PHP file at the time of execution.
PHP has a main configuration file (PHP.ini) which we use to enable error reporting and also used for turn on necessary extensions.
Now we check if we do not have any access to the php.ini configuration file then how can we turn on the error reporting.
Also Read: Complete Guide PHP Error Log
About PHP Error Reporting On And Off
Turn On PHP Error Reporting
Below source code shows all errors, warnings, and notices of the PHP program.
1 2 3 4 5 6 7 8 |
<?php //turn the display_errors setting to on ini_set('display_errors', 1); ini_set('display_startup_errors', 1); // Report all PHP errors error_reporting(E_ALL); ?> |
The ini_set function will try to override the PHP configuration file source code.
Turn Off PHP Error Reporting
Below source code is used for off all the type of PHP errors from the execution.
1 2 3 4 |
<?php // Turn off all error reporting error_reporting(0); ?> |
If user wants to turn on or off specific error reporting,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php // Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Report all errors except E_NOTICE error_reporting(E_ALL & ~E_NOTICE); // Report all PHP errors error_reporting(E_ALL); // Report all PHP errors error_reporting(-1); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ?> |
Here is the complete explanations of error reporting in PHP. Please let me know if you got any issue.
To know more you can check official site https://www.php.net/manual/en/.
Also Check:
- How JavaScript For Loop Works (Complete Guide With Example)
- Create Repository & Push Code To GitHub First Time
- Set-up Firebase Project using Firebase Console
Happy Coding..!
4 Replies to “Set PHP Error Reporting Into The PHP File”