How can you specify a custom exception message in PHP?

  • throw new Exception("Custom Exception Message");
  • By using the throw keyword with a user-defined exception class that extends the Exception class, you can specify a custom exception message.
  • Using the try...catch block
  • echo "Custom Exception Message";
To specify a custom exception message in PHP, you can use the throw statement with the new Exception("Custom Exception Message"). This creates a new Exception object with a custom message.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *