Easy Tutorial
❮ Func String Stripcslashes Func Simplexml Load File ❯

PHP var_export() Function

PHP Variable Handling Functions

The var_export() function is used to output or return a variable as a string representation.

The varexport() function returns the structure information of a variable passed to it, similar to vardump(), but the returned value is a valid PHP code.

PHP Version Requirements: PHP 4 >= 4.2.0, PHP 5, PHP 7

Syntax

mixed var_export ( mixed $expression [, bool $return ] )

Parameter Descriptions:

Return Value

Returns the structure information of the variable if $return is set to true.

Example

<?php
$a = array (1, 2, array ("a", "b", "c"));
var_export ($a);
?>

Output:

array (
  0 => 1,
  1 => 2,
  2 => 
  array (
    0 => 'a',
    1 => 'b',
    2 => 'c',
  ),
)

Optional parameter $return set to true:

<?php
$b = 3.1;
$v = var_export($b, TRUE);
echo $v;
?>

Output:

3.1

PHP Variable Handling Functions

❮ Func String Stripcslashes Func Simplexml Load File ❯