php8.5
Home/ Manual/ predefined / error/ Error::getTraceAsString

Error::getTraceAsString

PHP function Edit on GitHub ✎

(PHP 7, PHP 8)

Gets the stack trace as a string

Description

Error::getTraceAsString(): string

Returns the stack trace as a string.

Parameters Parameters

Return Values

Returns the stack trace as a string.

Examples

Error::getTraceAsString() example

php
<?php
function test() {
    throw new Error;
}

try {
    test();
} catch(Error $e) {
    echo $e->getTraceAsString();
}
?>

The above example will output something similar to:

output
#0 /home/bjori/tmp/ex.php(7): test()
#1 {main}

See Also

  • Throwable::getTraceAsString

Source: language/predefined/error/gettraceasstring.xml · from the official PHP manual (php/doc-en)