Menu Home

var_dump

osbo.com | PHP | Functions | var_dump

Dumps information about a variable

Syntax

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

Parameters

expression

The variable you want to dump.

...

Another variable ...

Return

No value is returned.

Examples

expression | bool

<?

$expression = false;

var_dump($expression);

?>
bool(false)

expression | int

<?

$expression = 0;

var_dump($expression);

?>
int(0)

expression | float

<?

$expression = 0.0;

var_dump($expression);

?>
float(0)

expression | string

<?

$expression = "0";

var_dump($expression);

?>
string(1) "0"

expression | array

<?

$expression = array(0, 1, array(0, 1));

var_dump($expression);

?>
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  array(2) {
    [0]=>
    int(0)
    [1]=>
    int(1)
  }
}

expression | object | standard class

<?

$expression = new stdclass;
$expression->var = 0;

var_dump($expression);

?>
object(stdClass)#1 (1) {
  ["var"]=>
  int(0)
}

expression | object | custom class

<?

class myclass {
    public $var;
}

$expression = new myclass;
$expression->var = 0;

var_dump($expression);

?>
object(myclass)#1 (1) {
  ["var"]=>
  int(0)
}

...

<?

class myclass {
    public $var;
}

$expression1 = false;
$expression2 = 0;
$expression3 = 0.0;
$expression4 = "0";
$expression5 = array(0, 1, array(0, 1));
$expression6 = new stdclass;
$expression6->var = 0;
$expression7 = new myclass;
$expression7->var = 0;

var_dump($expression1, $expression2, $expression3, $expression4, $expression5, $expression6, $expression7);

?>
bool(false)
int(0)
float(0)
string(1) "0"
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  array(2) {
    [0]=>
    int(0)
    [1]=>
    int(1)
  }
}
object(stdClass)#1 (1) {
  ["var"]=>
  int(0)
}
object(myclass)#2 (1) {
  ["var"]=>
  int(0)
}

Internal

print_r

var_export

External

PHP