w3resource

php.js : var_export() function

var_export() function

The var_export() function returns the structured information (only value) of a variable.

Version:

1103.1210

Syntax:

var_export(variable_name, set_value)

Parameters:

Name Description Required /
Optional
Type
variable_name The variable being exported. Required String
set_value If this parameter is used and set to true var_export() function returns the variable representation instead of outputting it. Optional Boolean

Value Type: Mixed*

*Mixed : mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Example of php.js var_export() function

In the following web document, var_dump() function displays structure (value) of various variables.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php.js : var_export() function example</title>
<script type="text/javascript" src="../../phpjs/variable/variable.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : var_export() function example</h1>
<h3>Outputs the value of variable.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
var_name1=678;
var_name2="a678";
var_name3="678";
var_name4="W3resource.com";
var_name5=698.99;
var_name6=125689.66;
var_array=new Array(99,'w3resource',67899.99);
var_export(var_name1);
document.write('<br />');
var_export(var_name2);
document.write('<br />');
var_export(var_name3);
document.write('<br />');
var_export(var_name4);
document.write('<br />');
var_export(var_name5);
document.write('<br />');
var_export(var_name6);
document.write('<br />');
var_export(var_array);
//]]>
</script>
</body>
</html>

Output of the function:

678
'a678'
'678'
'W3resource.com'
698.99
125689.66
array (    0 => 99,    1 => 'w3resource',    2 => 67899.99  )

View example of php.js var_export() function in browser

Download phpjs.zip

Previous: php.js : var_dump() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/phpjs/variable/var_export.php