Jump to content


Photo

var_dump() and print_r()


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 25 March 2006 - 02:42 PM

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

What the word print_r mean and do thank you.
print_r($whatever);

What var_dump in words mean and do thank you.
var_dump($whatever);


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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 25 March 2006 - 03:40 PM

var_dump () output the contents of a variable and also gives its data type and size if it's a string

$a = '';
$b = 42;
$c = 3.141;

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

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

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

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

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

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

)


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 25 March 2006 - 03:44 PM

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--]
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 25 March 2006 - 04:34 PM

In genrall how does the var_dump get to echo the messege to the screen amazing.

var_dump($john,$lucky);


Out put of var_dump($john)
string(8) "iam john" string(1) "1" 



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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users