var_representation
PECL var_representation >= 0.1.0
var_representation - Returns a short, readable, parsable string representation of a variable
Example #1 var_representation Examples
Result: [
1,
2,
[
'key' => 'value',
],
]
[1, 2, ['key' => 'value']]
Example #2 Escaping control characters
Result: "Content-Length: 123\r\n"
Example #3 Exporting stdClass
Result: (object) [
'name' => 'ElePHPant ElePHPantsdotter',
'website' => 'https://php.net/elephpant.php',
]
Example #4 Exporting classes
Result: \A::__set_state([
'var' => 5,
])
Example #5 Using __set_state()
Result: object(A)#2 (2) {
["var1"]=>
int(5)
["var2"]=>
string(3) "foo"
}