Jump to content

Need help formatting backtrace


eldan88

Recommended Posts

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

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.

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!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.