PHP var_export() Function
var_export()This function is used to output or return a variable, represented in string form.
var_export()The function returns structural information about the variable passed to the function; it isvar_dump()similar, except that what it returns is valid PHP code.
PHP Version Requirements: PHP 4 >= 4.2.0, PHP 5, PHP 7
Syntax
mixed var_export ( mixed $expression [, bool $return ] )
Parameter Description:
- $expression: The variable you want to output.
- $return: Optional. If set to TRUE, this function will not output the result, but will return the result to a variable.
Return Value
$returnThere is a return value only when set to true; it returns the structural information of the variable.
Example
Example
$a = array (1, 2, array ("a", "b", "c"));
var_export ($a);
The output result is:
array (
0 => 1,
1 => 2,
2 =>
array (
0 => 'a',
1 => 'b',
2 => 'c',
),
)
Optional Parameters$returnSet to true:
Example
$b = 3.1;
$v = var_export($b, TRUE);
echo $v;
The output result is:
3.1Other Extensions
PHP Available Functions