In this article, you will learn how to get the structured information about a variable in PHP. The var_export() function in PHP outputs or returns structured information about a variable.
This function works similar to var_dump(), except that the returned value for this function is valid PHP code.
what is the syntax of the VAR_EXPORT() function in php?
var_export(variable, return);
Parameters | Details |
---|---|
variable | Required. Specifies the variable to check |
return | Optional. If set to true, it returns the variable representation instead of outputting it |
examples of the VAR_EXPORT() function
Example 1. In this example, we output structured information about variables.
<?php
$a = 32;
echo var_export($a) . "<br>";
$b = "Hello world!";
echo var_export($b) . "<br>";
$c = 32.5;
echo var_export($c) . "<br>";
$d = array("red", "green", "blue");
echo var_export($d) . "<br>";
$e = array(32, "Hello world!", 32.5, array("red", "green", "blue"));
echo var_export($e) . "<br>";
?>