PHP Exception Constructor

PHP Exception Constructor


Definition :

In php Exception() constructor is used to create an Exception object and set some of its properties.

Syntax

   new Exception(message, code, previous)

Parameter 
Parameter Description
message Optional. A string describing why the exception was thrown
code Optional. An integer that can be used used to easily distinguish this exception from others of the same type
previous Optional. If this exception was thrown in a catch block of another exception, it is recommended to pass that exception into this parameter

Given below example of Exception() function 

Output :

Exception thrown in /home/TwT0ln/prog.php on line 8: [Code 1]
Division by zero