Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

var_export

Description

The var_export of Variable Handling for PHP outputs or returns a parsable string representation of a variable.

Syntax

var_export(
    mixed $value,
    bool $return = false
): ?string

Parameters

value

The variable to export.

return

If used and set to true, var_export() will return the variable representation instead of outputting it.

Return

Returns the variable representation when the return parameter is used and evaluates to true. Otherwise, this function will return null.

Examples

1 · value · bool

<?

$value = false;

var_export($value);

?>
false

2 · value · int

<?

$value = 0;

var_export($value);

?>
0

3 · value · float

<?

$value = 0.0;

var_export($value);

?>
0.0

4 · value · string

<?

$value = "0";

var_export($value);

?>
'0'

5 · value · array

<?

$value = array(0, 1, array(0, 1));

var_export($value);

?>
1090486272

6 · value · object · standard class

<?

$value = new stdclass;
$value->var = 0;

var_export($value);

?>
(object) array(
   'var' => 0,
)

7 · value · object · custom class

<?

class myclass
{
    public $var;
}

$value = new myclass;
$value->var = 0;

var_export($value);

?>
\myclass::__set_state(array(
   'var' => 0,
))

8 · return · false

<?

$value = 0;
$return = false;

$output = var_export($value, $return);

//var_export($output);

?>
0

9 · return · true

<?

$value = 0;
$return = true;

$output = var_export($value, $return);

//echo $output;

?>
HomeMenu