This article mainly introduces the var_export function of the output file in php format, describes the features and specific usage of the format output function var_export in the form of an instance, and has some reference value, for more information about var_export function in php format, see the following example. Share it with you for your reference. The details are as follows:
Var_export: php 4> = 4.2.0, php 5
Var_export -- output or returns a string representation of a variable.
Description: mixed var_export (mixed expression [, bool return])
This function returns the structure information about the variables passed to this function. it is similar to var_dump (). The difference is that the returned representation is legal php code, you can set the second parameter of the function to true to return the expression of the variable.
Example:
The code is as follows:
Var_export (array ('A', 'B', array ('A', 'BB ', 'CC') // This is no different from var_dump.
[Code] $ var = var_export (array ('A', 'B', array ('A', 'BB ', 'CC'), true) // after true is added, a variable is provided instead of being printed, so that the output can be directly made;
Echo $ var; // the output format is similar to that of var_dump.
Example 2:
The code is as follows:
$ Data = array ('name' => 'ABC', 'job' => 'grammer ', 'a' => array ('A', 'CC ', 'BB '));
$ Data = var_export ($ data, true );
Echo $ data;
The output format is as follows:
The code is as follows:
Array (
'Name' => 'ABC ',
'Job' => 'grammer ',
'A' =>
Array (
0 => 'A ',
1 => 'CC ',
2 => 'BB ',
),
)
I hope this article will help you with PHP programming.