Display the stack trace.
<?php function myFunction($num) { throw new Exception(“An error occurred”); } try { myFunction(5); } catch (Exception $e) { print_r($e->getTrace()); } ?> |
The getTrace() method returns a stack trace as an array.
Stack traces include information about all the functions executing at a specific moment. The stack trace returned by this method provides details about the stack at the time the exception was thrown.
$exception->getTrace() |
Return Value: |
Returns a stack trace as an array. |