tags:

views:

80

answers:

2

var_export function causes an exception while argument has circular references. Are there any alternatives (except serialize) which handle it correctly?

+2  A: 

Are you looking for var_dump or even debug_backtrace

Update:

Converting object to string

Sarfraz
I want to convert object to string. var_dump outputs it, I don't need this
darja
@darja: The only other way i know of is serializing it (although you say except it). See my updated answer as well.
Sarfraz
@Sarfraz Thanks for link. It sounds that I have two variants - serialize (which I don't want) and json_encode.
darja
@darja: yes it seems to be so. Thanks...
Sarfraz
A: 

You could try this :

ob_start();
var_dump($var);
$dump = ob_get_contents();
ob_end_clean();

And why can't you use serialize ?

DuoSRX
I need such converting for logs. And serialize output is too ugly for logs.
darja