PHP Syntax OOP Exceptions


- Info:

- Exceptions allow you to separate programming logic from error handling logic.

- Exceptions are caught by using try-catch structure and thrown by using throw keyword followed by Exception Object.

- Exceptions are derived from java.lang.Exception.


- Example:

- Creat PHP Console Application Test.php.




try {

throw new Exception();


catch (Exception $e) {

echo 'Caught exception: ', $e->getMessage(), "\n";