Example of the var_export function output file in php format,
This article describes how to use the var_export function in the php output file. 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:Copy codeThe 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:
Copy codeThe 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:
Copy codeThe 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.