In this article, you will learn how to declare try catch block in PHP. The try keyword in PHP is used to create a try…catch, or a try…catch…finally statement.
examples of the TRY keyword
Example 1. In this example, we use a try…catch statement to handle exceptions.
<?php
try {
throw new Exception("This is an exception");
} catch(Exception $e) {
echo $e->getMessage();
}
?>