Site icon T4Tutorials.com

Different Methods to Show Error Messages In PHP

Different Methods to Show Error Messages In PHP

PHP Errors

We use error functions to deal with error logging and error handling.

Types of Errors:

There are two types of errors:

  1. Internal Error

These are logical errors in code.

  1. External Error

These are errors related to the interactions of your code with the outside world.

Dealing with Error:

When we have figured out the error we can use the following ways to deal with them:

Showing Errors:

There are Four possible ways:

Turn off error reporting:

<?php
error_reporting(0);
?>

Report all errors:

<?php
error_reporting(E_ALL);
?>
<?php
ini_set("error_reporting", E_ALL);
?>

Report runtime errors:

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
?>

Report all Except E_Notice:

<?php
error_reporting(E_ALL & ~E_NOTICE);
?>

 

Exit mobile version