var_representation Returns a short, readable, parsable string representation of a variable &reftitle.description; stringvar_representation mixedvalue intflags0 var_representation (from the var_representation PECL) returns a string with structured information about the given variable. It is similar to var_export with differences in indentation, string escaping, and array representations. &reftitle.parameters; value The variable to generate a representation of. flags Bitmask consisting of VAR_REPRESENTATION_SINGLE_LINE, VAR_REPRESENTATION_UNESCAPED. The behaviour of these constants is described on the var_representation constants page. &reftitle.returnvalues; Returns the variable representation. &reftitle.examples; <function>var_representation</function> Examples 'value']]; echo var_representation($a), "\n"; echo var_representation($a, VAR_REPRESENTATION_SINGLE_LINE), "\n"; ?> ]]> &example.outputs; 'value', ], ] [1, 2, ['key' => 'value']] ]]> Escaping control characters &example.outputs; Exporting <classname>stdClass</classname> name = 'ElePHPant ElePHPantsdotter'; $person->website = 'https://php.net/elephpant.php'; echo var_representation($person); ]]> &example.outputs; 'ElePHPant ElePHPantsdotter', 'website' => 'https://php.net/elephpant.php', ] ]]> Exporting classes var = 5; echo var_representation($a); ?> ]]> &example.outputs; 5, ]) ]]> Using <link linkend="object.set-state">__set_state()</link> var1 = $an_array['var1']; $obj->var2 = $an_array['var2']; return $obj; } } $a = new A; $a->var1 = 5; $a->var2 = 'foo'; eval('$b = ' . var_representation($a) . ';'); // $b = \A::__set_state([ // 'var1' => 5, // 'var2' => 'foo', // ]); var_dump($b); ?> ]]> &example.outputs; int(5) ["var2"]=> string(3) "foo" } ]]> &reftitle.seealso; var_export