Thursday, January 22, 2026
HomeLanguagesPHP | var_export() Function

PHP | var_export() Function

The var_export() is a built-in function in PHP which is used to return the structured value(information) of a variable that is passed to this function as a parameter. This function is similar to the var_dump() function.
Syntax
 

var_export($var, $return)

Parameters: This function accepts two parameters as shown in the above syntax and are described below: 
 

  • $var: This parameter represents the variable to be exported.
  • $return: This is an optional parameter and is of boolean type. In case it is used and set to true then this function returns the variable representation instead of outputting it. The default value of this parameter is FALSE.

Return Type: It returns the variable representation if $return parameter is used and set to true otherwise this function returns NULL.
Below programs illustrate the var_export() function:
Program 1
 

php




<?php
// PHP program to illustrate
// the var_export() function
 
$var = '11.89';
 
$res = var_export($var, true);
 
echo $res;
 
?>


Output: 
 

'11.89'

Program 2
 

php




<?php
// PHP program to illustrate
// the var_export() function
 
$var = +11.99;
 
$res = var_export($var);
 
echo $res ;
 
?>


Output: 
 

11.99

Reference
http://php.net/manual/en/function.var-export.php
 

RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS