eldan88 Posted July 23, 2013 Share Posted July 23, 2013 Hey, I am trying to format back trace in a nice readable format, but I having troubles doing so. I tried using print_r function but it is not working. Any suggestion on how to format backtrace? Below is my code function a($arg) { b("Bob"); } function b($arg) { d('delta'); } function d ($arg) { var_dump(debug_backtrace()); } a('alpha') Link to comment https://forums.phpfreaks.com/topic/280423-need-help-formatting-backtrace/ Share on other sites More sharing options...
Psycho Posted July 23, 2013 Share Posted July 23, 2013 What do you mean "it is not working"? Exactly what are you getting? The code you have above does exactly what I expect - it outputs the array returned from the debug_backtrace() function. EDIT: If your issue is that the array output is not "pretty" then the issue is an HTML problem and not a PHP problem (and this is in the wrong forum). There are many options to make the output pretty. The most straightforward is putting it within PRE tags so white-space and line-breaks are rendered in the HTML display. function d ($arg) { echo "<pre>"; var_dump(debug_backtrace()); echo "</pre>"; } Otherwise you can create your own code to loop through the array and format the output any way you want. Link to comment https://forums.phpfreaks.com/topic/280423-need-help-formatting-backtrace/#findComment-1441786 Share on other sites More sharing options...
requinix Posted July 23, 2013 Share Posted July 23, 2013 debug_print_backtrace Link to comment https://forums.phpfreaks.com/topic/280423-need-help-formatting-backtrace/#findComment-1441813 Share on other sites More sharing options...
eldan88 Posted July 23, 2013 Author Share Posted July 23, 2013 What do you mean "it is not working"? Exactly what are you getting? The code you have above does exactly what I expect - it outputs the array returned from the debug_backtrace() function. EDIT: If your issue is that the array output is not "pretty" then the issue is an HTML problem and not a PHP problem (and this is in the wrong forum). There are many options to make the output pretty. The most straightforward is putting it within PRE tags so white-space and line-breaks are rendered in the HTML display. function d ($arg) { echo "<pre>"; var_dump(debug_backtrace()); echo "</pre>"; } Otherwise you can create your own code to loop through the array and format the output any way you want. I was trying to out put in pretty HTML but the pre tags did the job! Thanks!! Link to comment https://forums.phpfreaks.com/topic/280423-need-help-formatting-backtrace/#findComment-1441858 Share on other sites More sharing options...
eldan88 Posted July 23, 2013 Author Share Posted July 23, 2013 debug_print_backtrace Thank you the the tip requinix! Link to comment https://forums.phpfreaks.com/topic/280423-need-help-formatting-backtrace/#findComment-1441859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.