PHP catch Keyword

Trusted SSL from just $3.44
Advertisements
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
close

Stay up-to-date about PHP!

We don’t spam!

Trusted SSL from just $3.44
Advertisements
Trusted SSL from just $3.44
Advertisements

en English
X
Scroll to Top