Jump to content

var_dump() and print_r()


redarrow

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.
Link to comment
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]

Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.