PHP catch Keyword

PHP class Keyword
PHP callable Keyword

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();
}
?>
PHP class Keyword
PHP callable Keyword
en English
X
Scroll to Top