Display the stack trace.
<?php function myFunction($num) { throw new Exception(“An error occurred”); } try { myFunction(5); } catch (Exception $e) { print_r($e->getTraceAsString()); } ?> |
The getTraceAsString() method returns the stack trace as a string.
Stack traces provide details about all the functions executing at a specific moment. This method’s stack trace reflects the state of the stack when the exception was thrown.
$exception->getTraceAsString() |
Return Value: |
Returns the stack trace as a string. |