0

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?

2

1 Answer 1

1

Some approaches:

$debugStr = print_r(debug_backtrace(), true);
echo $debugStr;
// or
ob_start();
debug_print_backtrace();
$debugStr = ob_get_clean();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I didn't know (or forgot) about print_r.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.