Throw an exception and display its code.
| <?php try { throw new Exception(“An error occurred”, 120); } catch(Exception $e) { echo “Error code: “ . $e->getCode(); } ?> |
The getCode() method returns an integer that can be used to identify the exception.
| $exception->getCode() |
|
Return Value: |
Returns an integer value. |