PHP Interview questions

Total available count: 33
Subject - PHP Frameworks
Subsubject - PHP

What is the difference between var_dump() vs print_r()?

The var_dump function displays structured data about variables/expressions including its type and value. Arrays are explored recursively with values indented to show structure. It also shows which array values and object properties are references.

The print_r() displays data about a variable in a way that's readable by humans. Array values will be presented in a format that shows keys and elements. Similar notation is used for objects.


$obj = (object) array('Qualityjoint', 'Technologies', 'India');
var_dump($obj) will display below output in the screen.
object(stdClass)#1 (3) { [0]=> string(12) "Qualityjoint" [1]=> string(12) "Technologies" [2]=> string(5) "India"}
And, print_r($obj) will display below output in the screen.
stdClass Object ( [0] => Qualityjoint [1] => Technologies [2] => India)


Next 5 interview question(s)

What is the use of var_dump() function?
What is Type Juggling and Type casting?
What is the difference between FUNCTION and METHOD?
What are Magic constants?
How to define constants?