PHP var_dump() Function

PHP var_dump() Function

The var_dump() function in PHP is used to dump the information about a variable. It displays the structured information (arrays and objects) about one or more expressions. This function is also effective with expressions.

Syntax

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

Parameter

expression(required)- This parameter represents the variable you want to dump.

Return

NA

Example 1

 

Output

After using echo() function...
Hello PHP
After using var_dump() function...
string(9) "Hello PHP" 

Example 2

 

Output

bool(false)
bool(false)
bool(false) 

Example 3

 

Output

int(12)
 float(12.11)
 bool(true)
 array(4) {
   [0]=>
   int(11) 
   [1]=>
   int(12)
   [2]=>
   int(13)
   [3]=>
   int(14) 
 }
 NULL 

Example 4

subjects);
 }
 $state_name = new stdClass;
 $state_name->subjects = Array('Haryana', 'Punjab', 'Rajasthan');
 var_dump(get_state($state_name));
 ?> 

Output

array(3) {
   [0]=>
   string(7) "Haryana"
   [1]=>
   string(6) "Punjab"
   [2]=>
   string(9) "Rajasthan"
 }