Home > Article > Backend Development > PHP var_export function example explanation
The var_export() function returns structural information about the variable passed to the function. It is similar to var_dump(), except that the representation returned is legal PHP code. var_export must return legal PHP code. In other words, the code returned by var_export can be directly assigned to a variable as PHP code. And this variable will get the same type of value as var_export.
The example in this article describes the usage of the var_export function of the PHP format output file. Share it with everyone for your reference. The details are as follows:
var_export(array('a','b',array('aa','bb','cc')))//这种与var_dump没什么区别 [code]$var =var_export(array('a','b',array('aa','bb','cc')),true)//加上true后,不会再打印出来,而是给了一个变量,这样就可以直接输出; echo $var;//此时输出来的形式与var_dump()打印的相似.
Example 2, the code is as follows:
The code is as follows:
$data = array ('name' => 'abc', 'job' => 'programmer','a'=>array('aa','cc','bb')); $data = var_export($data,true); echo $data;
The output form is as follows:
array ( 'name' => 'abc', 'job' => 'programmer', 'a' => array ( 0 => 'aa', 1 => 'cc', 2 => 'bb', ), )
The above is the detailed content of PHP var_export function example explanation. For more information, please follow other related articles on the PHP Chinese website!