Skip to content
Related Articles

Related Articles

Improve Article

How to show All Errors in PHP ?

  • Last Updated : 10 May, 2021
Geek Week

We can show all errors in PHP using the error_reporting() function. It sets the error_reporting directive at runtime according to the level provided. If no level is provided, it will return the current error reporting level. error_reporting(E_ALL) level represents all errors, warnings, notices, etc.

PHP Code: If the level is set to zero, no error is reported even when an unavailable file is included.

PHP




<?php
   //setting error reporting to zero
  error_reporting(0);
  //including a file that is not present
  include(gfg.php);
?>

Output:

No output
No error is reported

PHP Code:

When the level is set to E_ALL, all the errors including all warnings and notices are reported.



PHP




<?php
    //setting error reporting to all errors
  error_reporting(E_ALL);
   //including a file that is not present
  include(gfg.php);
?>

Output:

PHP Notice: Use of undefined constant gfg – assumed ‘gfg’ in /home/36649711d0ef1764ba295676144de779.php on line 5
PHP Notice: Use of undefined constant php – assumed ‘php’ in /home/36649711d0ef1764ba295676144de779.php on line 5
PHP Warning: include(gfgphp): failed to open stream: No such file or directory in /home/36649711d0ef1764ba295676144de779.php on line 5

References: https://www.php.net/manual/en/function.error-reporting.php, https://www.geeksforgeeks.org/php-types-of-errors/

My Personal Notes arrow_drop_up
Recommended Articles
Page :