Throw an exception and then display its message.
| <?php try { throw new Exception(“An error occurred”); } catch(Exception $e) { echo $e->getMessage(); } ?> |
The getMessage() method returns a description of the error or issue that caused the exception to be thrown.
| $exception->getMessage() |
|
Return Value: |
Returns a string value. |