Back to Top

PHP Error Reporting Levels

Types of Error Levels in PHP

PHP error_reporting can help you to set the level of the error in log report and using log, you can easily identify the errors in your code.

Basically, PHP error is categorized by error levels for various kind of errors and its define all kinds of error from notice to fatal errors.The error level defines the seriousness and importance of errors.Most of the errors may be caught with a custom error handler, but some are unrecoverable.

How to use error_reporting function?

The error_reporting() function is used to set the level of PHP error and return to the current level.

You can set up an error level in php.ini. By default, PHP will report all errors except notice.Error reporting level can be set through a number of predefined constants available in PHP for errors.

Generally To set the levels of error in the PHP web application, error_reporting(), the function is useful.We can set error levels like

int error_reporting(E_ERROR | E_WARNING | E_NOTICE | E_PARSE);

How to Turn off all Errors?

To Turn off all levels of errors, we can use the same function error_reporting with value 0.


How to Turn on all Errors?

To Turn on all levels of errors, we can use the same function error_reporting with value E_ALL which can be used “or” condition so that all types errors can be reported.

error_reporting (E_ALL); // Report All Bugs

Error Levels Types

Let’s one by one see basic types of error level.Before dive into the error levels, if you want to learn how you can log errors, learn about the LOG of PHP, MySQL and Apache here.


This is a fatal, unrecoverable error. Examples for E_ERROR are uncaught exe or class redeclaration.It is Run-time error and it will prevent the execution of code.



This is the most common kind of error. It normally occurs when something you tried and doing went wrong. Examples are missing function parameters or division by zero.


The interesting part of this error level is the only one not included in the E_ALL constant. The Main and important reason is it is easy to convert from PHP 4 to PHP 5 and you can still run PHP 4 code in PHP 5.


Notices are the specifies that the code runs in the browser may be doing something unintentional like trying to read the undefined variable. It is good practice to develop with notices enabled so your code is “notice-free” before the move to live.


Parse errors occur at the time of compiling a code and its stop the execution of code if any error occurs during parse.


It’s an internal PHP error which occurs if any PHP extension fails to start.It occurrs in the initialization process starts.


It’s used when any user-defined error occurs and stop the execution of PHP code. User-defined errors (E_USER_*) are never caused by PHP itself.


It’s used when any user-defined notice occurs.It is similar to E_NOTICE.

In development server, You can enable all error, but it is recommended to disable warning and notice on the production server.

These are the detailed usage of PHP error_reporting and error levels.Do you think any error levels in PHP we missed here? share your experiences with us on the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to get Last Post in WordPress

Posted on 6 years ago


How to allow more MIME types in WordPress

Posted on 6 years ago


Angularjs 2 Tutorial for Beginners

Posted on 2 years ago


Hello world

Updated 5 days ago

Nick Carter

In depth Understanding of Laravel Core

Updated 2 months ago


ECMAScript 6 New Features – 2

Updated 1 year ago


The Reader’s Poll – June 2015

Posted on 4 years ago


The Reader’s Poll – August 2014

Posted on 4 years ago


The Reader’s Poll – June 2014

Posted on 5 years ago


The Readers’ Poll – May 2014

Posted on 5 years ago


The Readers’ Poll – August 2013

Posted on 5 years ago