PHP Introduction | Functions | var_dump - Output Variable Information
var_dump is a function that outputs information about variables. It is available in PHP 4 and later.
Syntax
var_dump( $var1, $var2, … );
- Return value
- Does not return a value.
- Interpretation
- int(1): An integer whose value is 1.
- float(1.1): A floating-point number whose value is 1.1.
- string(5) “hello”: A string consisting of 5 characters, with the value
hello. - array(2) { [0]=> int(1) [1]=> float(1.1) }: An array with 2 values; the first value is integer 1, and the second value is floating-point number 1.1.
- bool(true): A Boolean whose value is true.
Example
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>PHP</title>
<style>
body {
line-height: 2;
font-family: "Consolas", monospace;
font-style: italic;
font-size: 20px;
}
</style>
</head>
<body>
<?php
$a = 1;
var_dump( $a );
echo "<br>";
$b = 1.1;
var_dump( $b );
echo "<br>";
$c = "hello";
var_dump( $c );
echo "<br>";
$d = array( $a, $b );
var_dump( $d );
echo "<br>";
$e = true;
var_dump( $e );
?>
</body>
</html>