xxxxxxxxxx
try {
throw new Exception("Some error message");
} catch(Exception $e) {
echo $e->getMessage();
}
xxxxxxxxxx
<?php
// Set error message
$errorMsg = "An error occurred.";
// Display error message using echo
echo $errorMsg;
// Display error message using die()
// die($errorMsg); // Uncomment this line to terminate the script
// Rest of your code...
?>