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.

Example: 

$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)

1
What is the use of ::class?
2
What is the use of var_dump() function?
3
What is Type Juggling and Type casting?
4
What is Void?
5
Who is father of PHP?


Comments