php var dump vs print r

0 votes

What is the difference between var_dump() and print_r() in terms of spitting out an array as a string?

May 28, 2022 in PHP by Kichu
• 19,040 points
619 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The var_dump function - Displays structured information about variables/expressions including their type and value

The print_r() function - Displays information about a variable in a way that's readable by humans. array values will be presented in a format that shows keys and elements

Example:

$obj = (object) array('qualitypoint', 'technologies', 'India');

Output by var_dump($obj):

object(stdClass)#1 (3) {
 [0]=> string(12) "qualitypoint"
 [1]=> string(12) "technologies"
 [2]=> string(5) "India"
}

Output by print_r($obj):

stdClass Object ( 
 [0] => qualitypoint
 [1] => technologies
 [2] => India
)

I hope this helps.

answered May 30, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In PHP

0 votes
1 answer

How to Debug Variables like in PHP var_dump()?

Hello @kartik, Try out with the Smarty Session: {$smarty.session|@debug_print_var} or {$smarty.session|@print_r} To ...READ MORE

answered Apr 20, 2020 in PHP by Niroj
• 82,840 points
1,691 views
0 votes
0 answers

PHP | define() vs. const

In PHP, there are two ways to ...READ MORE

Jun 1, 2022 in PHP by Kichu
• 19,040 points
1,054 views
0 votes
0 answers

PHP "php://input" vs $_POST

I want to know what is the ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,040 points
740 views
0 votes
0 answers

PHP Elvis operator vs null coalescing operator

Can someone clarify the differences between PHP's ...READ MORE

Aug 3, 2022 in PHP by Kithuzzz
• 38,000 points
822 views
0 votes
0 answers

getenv() vs. $_ENV in PHP

What is the distinction between $_ENV and ...READ MORE

Aug 8, 2022 in PHP by narikkadan
• 63,600 points
1,895 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,840 points
3,406 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,250 points
6,313 views
0 votes
1 answer

How to store input value into array then localstorage?

Hello @ abhittac, You have create the array everytime the ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,840 points
9,357 views
0 votes
1 answer

Convert a PHP object to an associative array

Start with simply typecasting the line:- $array = ...READ MORE

answered Feb 23, 2022 in PHP by Aditya
• 7,680 points
2,294 views
0 votes
0 answers

How can I sort arrays and data in PHP?

How do I sort an array in ...READ MORE

May 29, 2022 in PHP by Kichu
• 19,040 points
612 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP