programming

What’s different var_dump VS print_r in PHP

By Hamdy Gamal

May 08, 2021

The var_dump function displays structured information 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 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. Similar notation is used for objects.

Example:

var_dump($obj) will display below output in the screen.

And, print_r($obj) will display below output in the screen.