Tutorialspoint.dev

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 boolead type. In case it is used and set to true then this function returns the variable reprentation 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 program to illustrate
// the var_export() function
  
$var = '11.89';
  
$res = var_export($var, true);
  
echo $res;
  
?>

/div>

Output:

'11.89'

Program 2:

<?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



This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter