getTraceAsString
Returns the same information as getTrace(), but in the form of a string.
getTraceAsString()
method returns the stack trace as a string.
The stack trace contains information about all functions running at a given moment. The stack trace provided by this method contains stack information when an exception is thrown.
Tutorial: PHP exception
Reference Manual: getTrace() method
Output stack trace:
<?php function myFunction ( $num ) { throw new Exception ( "An error occurred" ) ; } try { myFunction ( 5 ) ; } catch ( Exception $e ) { print_r ( $e -> getTraceAsString ( ) ) ; } ?>
Try it yourself
$exception -> getTraceAsString ( )