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') Quote Link to comment Share on other sites More sharing options...
Solution Psycho Posted July 23, 2013 Solution Share Posted July 23, 2013 (edited) 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. Edited July 23, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
requinix Posted July 23, 2013 Share Posted July 23, 2013 debug_print_backtrace Quote Link to comment Share on other sites More sharing options...
eldan88 Posted July 23, 2013 Author Share Posted July 23, 2013 (edited) 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!! Edited July 23, 2013 by eldan88 Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.