the
the

Reputation: 21911

How to convert debug_stacktrace() into a string?

I want to send an email with a stack trace. What's a good way to convert debug_stacktrace() into a string?

If I do implode("\n", debug_backtrace())) I get a repetition of Array Array Array, I can also try to make things more complicated, e.g. writing code to handle specific parts, or I can try to capture the output of debug_print_backtrace into a variable.

But ideally I'd like a simple solution for this. Is there one?

Upvotes: 0

Views: 1079

Answers (1)

u_mulder
u_mulder

Reputation: 54841

Some approaches:

$debugStr = print_r(debug_backtrace(), true);
echo $debugStr;
// or
ob_start();
debug_print_backtrace();
$debugStr = ob_get_clean();

Upvotes: 1

Related Questions