Example explained:
The code above tests if the email-address contains the string "example" in it, if it does, the exception is re-thrown:
The customException() class is created as an extension of the old exception class. This way it inherits all methods and properties from the old exception class
The errorMessage() function is created. This function returns an error message if an e-mail address is invalid
The $email variable is set to a string that is a valid e-mail address, but contains the string "example"
The "try" block contains another "try" block to make it possible to re-throw the exception
The exception is triggered since the e-mail contains the string "example"
The "catch" block catches the exception and re-throws a "customException"
The "customException" is caught and displays an error message
If the exception is not caught in its current "try" block, it will search for a catch block on "higher levels".