In this article, you will learn how to use try catch block in PHP. The catch keyword in PHP is used to handle exceptions that are thrown by the code in a preceding try block.
examples of the CATCH keyword
Example 1. In this example, we catch an exception.
<?php
try {
throw new Exception("This is an exception");
} catch(Exception $e) {
echo $e->getMessage();
}
?>