Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

getMessage()

Example

Throw an exception and then display its message.

<?php
try {
  throw new Exception(“An error occurred”);
catch(Exception $e) {
  echo $e->getMessage();
}
?>

Definition and Usage

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

Syntax

$exception->getMessage()

Technical Details

 

Return Value:

Returns a string value.