Open In App

PHP | var_export() Function

Last Updated : 03 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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
 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads