Monday, February 2, 2015

PHP : var_dump() function with Example and description.

Description

The var_dump() function is used to display structured information (type and value) about one or more variables.
var_dump -- Dumps information about a variable

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.  

Version

(PHP 4 and above)
Syntax

var_dump(variable1, variabl2, ....variablen)

Parameter
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.
Return value

Nothing

Example -1 :
view plainprint?

    <?php
    $var_name1=678;
    $var_name2="a678";
    $var_name3="678";
    $var_name4="W3resource.com";
    $var_name5=698.99;
    $var_name6=+125689.66;          
    echo var_dump($var_name1)."<br>";
    echo var_dump($var_name2)."<br>";
    echo var_dump($var_name3)."<br>";
    echo var_dump($var_name4)."<br>";
    echo var_dump($var_name5)."<br>";
    echo var_dump($var_name6)."<br>";
    ?>        

Output :

int(678)
string(4) "a678"
string(3) "678"
string(14) "W3resource.com"
float(698.99)
float(125689.66)