PHP Exception getMessage() Method

PHP Exception getMessage Method


Definition :

The getMessage() method is used to returns a description of the error or behaviour that caused the exception to be thrown.

Syntax

   $exception->getMessage()

Parameters

     No parameter is required.

Return Value

     Returns the Exception message as a string.

Given below example throw an exception and then output its message:

Output : Found Error