var_dump

(PHP 3>= 3.0.5, PHP 4 , PHP 5)

var_dump -- Dumps information about a variable

Description

void var_dump ( mixed expression [, mixed expression [, ...]] )

This function displays structured information about one or more expressions that includes its type and value. Arrays and objects are explored recursively with values indented to show structure.

In PHP 5 only public, private and protected properties of objects will be returned in the output.

提示: 任何直接把輸出到瀏覽器的結果,可使用輸出控制函數來擷取此函數的輸出,再將之存入一個字串(舉例說明)。

範例 1. var_dump() example

<?php
$a
= array (1, 2, array ("a", "b", "c"));
var_dump($a);
?>

The above example will output:

array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(3) {
    [0]=>
    string(1) "a"
    [1]=>
    string(1) "b"
    [2]=>
    string(1) "c"
  }
}
<?php

$b
= 3.1;
$c = true;
var_dump($b, $c);

?>

The above example will output:

float(3.1)
bool(true)

See also var_export() and print_r().