PHP format output file var_export function example,
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:php 4 >= 4.2.0, php 5
var_export -- Export or return a string representation of a variable.
Description: mixed var_export (mixed expression [,bool return])
This function returns structural information about the variables passed to the function. It is similar to var_dump(), except that the representation it returns is legal PHP code. You can do this by setting the second parameter of the function to true , thereby returning the representation of the variable.
Example:
Copy code The code is as follows:
var_export(array('a','b',array('aa',' bb','cc')))//This is no different from var_dump
[code]$var =var_export(array('a','b',array('aa','bb','cc')),true)//After adding true, it will not be printed anymore, but A variable is given so that it can be output directly;
echo $var;//The output form at this time is similar to that printed by var_dump().
Example 2, the code is as follows:
Copy code 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 format is as follows:
Copy code The code is as follows:
array (
'name' => 'abc',
'job' => 'programmer',
'a' =>
array (
0 => 'aa',
1 => 'cc',
2 => 'bb',
),
)
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/912281.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/912281.htmlTechArticlePHP format output file var_export function example. This example describes the usage of PHP format output file var_export function. Share it with everyone for your reference. The details are as follows: var_export:php...