Home >Backend Development >PHP Tutorial >Output legal php format files var_export_PHP tutorial

Output legal php format files var_export_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-20 11:01:31860browse

var_export
(php tutorial 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 returned is legal PHP code.
You can return a representation of a variable by setting the second parameter of the function to true.
eg:

var_export(array('a','b',array('aa','bb','cc'))) This is no different from var_dump;

$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().
eg2
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:
The code is as follows:

array (
'name' => 'abc',
'job' => 'programmer',
'a' =>
array (
0 => 'aa',
1 => 'cc',
2 => 'bb',
),
)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445435.htmlTechArticlevar_export (php tutorial 4 = 4.2.0, php 5) var_export -- Output or return a variable string Representation description mixed var_export ( mixed expression [, bool return] ) This function returns information about...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn