var_representationReturns a short, readable, parsable string representation of a variable Description
string var_representation(mixed
$value , int $flags = 0)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. Parameters
Return ValuesReturns the variable representation. Examples
Example #1 var_representation Examples
The above example will output: [ 1, 2, [ 'key' => 'value', ], ] [1, 2, ['key' => 'value']]
Example #2 Escaping control characters
The above example will output: "Content-Length: 123\r\n"
Example #3 Exporting stdClass
The above example will output: (object) [ 'name' => 'ElePHPant ElePHPantsdotter', 'website' => 'https://php.net/elephpant.php', ]
Example #4 Exporting classes
The above example will output: \A::__set_state([ 'var' => 5, ])
Example #5 Using __set_state()
The above example will output: object(A)#2 (2) { ["var1"]=> int(5) ["var2"]=> string(3) "foo" } See Also
|