An exception is an object that describes an error or unexpected behaviour of a PHP script.
To avoid the error from being thrown and stopping script execution, we can use a try...catch block to catch the exception and run some code instead.
Edit the code below and click Run to see the result live.