var_export
PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8
var_export - Outputs or returns a parsable string representation of a variable
Example #1 Using __set_state()
Result: object(A)#2 (2) {
["var1"]=>
int(5)
["var2"]=>
string(3) "foo"
}
Example #2 var_export Examples
Result: array (
0 => 1,
1 => 2,
2 =>
array (
0 => 'a',
1 => 'b',
2 => 'c',
),
)
Example #3 Exporting stdClass (since PHP 7.3.0)
Result: (object) array(
'name' => 'ElePHPant ElePHPantsdotter',
'website' => 'https://php.net/elephpant.php',
)
Example #4 Exporting classes
Result: A::__set_state(array(
'var' => 5,
))