Tuesday, September 24, 2024
Google search engine
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

Recent Comments