1

I want to debug an application with debug_backtrace() in the __set function.

As I need it as a string I tried it with $myStringVar = print_r(debug_backtrace(),true);

But this doesn't work. I found out that there are some objects in my array that debug_backtrace() returns.

So I have to convert it another way to a string with ignoring the objects.

But how to do this?

Keksdose
  • 17
  • 6
  • You can call `debug_backtrace(0)` to avoid objects. Anyway `debug_backtrace` returns arrays, not strings: see [documentation](http://php.net/manual/en/function.debug-backtrace.php) for more details! – fusion3k Jan 25 '16 at 14:26
  • Hi, tried it with debug_backtrace(0) but it seems it crashes again when calling print_r(debug_backtrace(0),true). I've put it into a try catch(\Exception $e) to get all Exceptions but it doesn't get into the catch, it just stops. – Keksdose Jan 25 '16 at 14:39
  • Are You sure that `__set()` is called? – fusion3k Jan 25 '16 at 14:53

1 Answers1

0

Use http_build_query, ie

$mysStringVar = http_build_query(debug_backtrace());
devpro
  • 16,184
  • 3
  • 27
  • 38
Craig
  • 456
  • 5
  • 14
  • Devpro, what was your edit? It looks like you rewrote what I wrote. – Craig Jan 25 '16 at 14:42
  • if I use http_build_query(debug_backtrace)); $myStringVar contains only "Evaluating..." which is no useable backtrace for me :/ – Keksdose Jan 25 '16 at 14:51