var_representationReturns a short, readable, parsable string representation of a variable 説明
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. パラメータ
戻り値Returns the variable representation. 例
例1 var_representation Examples 上の例の出力は以下となります。
[
1,
2,
[
'key' => 'value',
],
]
[1, 2, ['key' => 'value']]
例2 Escaping control characters 上の例の出力は以下となります。 "Content-Length: 123\r\n"
例3 Exporting stdClass 上の例の出力は以下となります。 (object) [ 'name' => 'ElePHPant ElePHPantsdotter', 'website' => 'https://php.net/elephpant.php', ]
例4 Exporting classes 上の例の出力は以下となります。 \A::__set_state([ 'var' => 5, ])
例5 Using __set_state() 上の例の出力は以下となります。
object(A)#2 (2) {
["var1"]=>
int(5)
["var2"]=>
string(3) "foo"
}
参考
|