w3resource

php.js : var_dump() function

var_dump() function

The var_dump() function returns structured information (value and type) about one or more variables.

Version:

1103.1210

Syntax:

var_dump(variable1, variable2, ....variablen)

Parameters:

Name Description Required /
Optional
Type
variable1
variable2
---------
variablen

The variable being checked Required Mixed*

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

Example of php.js var_dump() function:

In the following web document, var_dump() function displays structure (type and 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_dump() function example1</title>
<script type="text/javascript" src="../../phpjs/variable/variable.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : var_dump() function example1</h1>
<h3>String representation of the structure of a 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_dump(var_name1);
document.write('<br />');
var_dump(var_name2);
document.write('<br />');
var_dump(var_name3);
document.write('<br />');
var_dump(var_name4);
document.write('<br />');
var_dump(var_name5);
document.write('<br />');
var_dump(var_name6);
document.write('<br />');
var_dump(var_array);
//]]>
</script>
</body>
</html>

Output of the function:

int(678)
string(4) "a678"
string(3) "678"
string(14) "W3resource.com"
float(698.99)
float(125689.66)
array(3) { [0] => int(99) [1] => string(10) "w3resource" [2] => float(67899.99)} 

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

Download phpjs.zip

Previous: php.js : unserialize() function
Next: php.js : var_export() function



Share this Tutorial / Exercise on : Facebook and Twitter