Different Methods to Show Error Messages In PHP

By: Prof. Fazal Rehman Shamil

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:

  • Display the Error: This shows the error to the developer and/or user when the program is executed.
  • Log the Error: Store the errors and review them from a textual log file
  • Act on the Error: Each program will need a different type of action.
  • Ignore the Error: This should continually be avoided.

Showing Errors:

There are Four possible ways:

  • error_reporting()
  • display_errors()
  • log_errors()
  • error_log string()

Turn off error reporting:

Report all errors:

Report runtime errors:

Report all Except E_Notice:

 

Prof. Fazal Rehman Shamil
Latest posts by Prof. Fazal Rehman Shamil (see all)