An exception can carry a short message that explains the failure.

Exception Message

exception_message.php
<?php
$age = ;

try {
    if ($age < 18) {
        throw new Exception("too young");
    }

    $message = "allowed";
} catch (Exception $error) {
    $message = $error->getMessage();
}

echo "age=" . $age . "\n";
echo "message=" . $message . "\n";
<?php
$age = ;

try {
    if ($age < 18) {
        throw new Exception("too young");
    }

    $message = "allowed";
} catch (Exception $error) {
    $message = $error->getMessage();
}

echo "age=" . $age . "\n";
echo "message=" . $message . "\n";
<?php
$age = ;

try {
    if ($age < 18) {
        throw new Exception("too young");
    }

    $message = "allowed";
} catch (Exception $error) {
    $message = $error->getMessage();
}

echo "age=" . $age . "\n";
echo "message=" . $message . "\n";
message The message is data; the catch block decides whether to expose it.