Output the 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 »
The getTraceAsString()
method returns a stack trace in the form of a string.
Stack traces contain information about all of the functions that are running at a given moment. The stack trace provided by this method has information about the stack at the time that the exception was thrown.
$exception->getTraceAsString()
Return Value: | Returns a stack trace in the form of a string |
---|
Read more about Exceptions in our PHP Exceptions Chapter.
PHP Reference: The getTrace() Method.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!