Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

var_dump() and print_r()

Recommended Posts

Please exsplain the meaning of the two statements in deatails please thank you.

What the word print_r mean and do thank you.
[code]
print_r($whatever);
[/code]

What var_dump in words mean and do thank you.
[code]
var_dump($whatever);
[/code]


Currently working on all arrays statements and functions for my collage work need to understand the above clearly and in deatil thank you.

As much info as possable in deth thank you.

Share this post


Link to post
Share on other sites
var_dump () output the contents of a variable and also gives its data type and size if it's a string

[code]$a = '';
$b = 42;
$c = 3.141;

var_dump($a); //--> string(0) ""
var_dump($b); //--> int(42)
var_dump($c); //--> float(3.141)[/code]

print_r() is a recursive print function and is used view contents of arrays or objects. Use within <pre>..</pre> tags for more readable output

[code]$var = array(
       'abc' => array(1,2,3),
       'def' => array(4,5,6)
);

echo '<pre>',print_r($var, true), '</pre>';[/code]

gives-->
[code]Array
(
    [abc] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [def] => Array
        (
            [0] => 4
            [1] => 5
            [2] => 6
        )

)[/code]

Share this post


Link to post
Share on other sites
barand thank you so much for your reply and time.

[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]
solved[!--sizec--][/span][!--/sizec--]

Share this post


Link to post
Share on other sites
In genrall how does the var_dump get to echo the messege to the screen amazing.

[code]
var_dump($john,$lucky);
[/code]


Out put of var_dump($john)
[code]
string(8) "iam john" string(1) "1"
[/code]



Is it becouse var_dump() is a built in function that the php can process the ouput throw the designed files within the php.ini.

Or does var mean varable and dump as dumping the varable to screen and dumps the string to screen with the built in file throw php.ini.

Thank you.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.