How to get xdebug or var_dump to show full object/array with PHP?

Spread the love

Sometimes, we want to get xdebug or var_dump to show full object/array with PHP.

In this article, we’ll look at how to get xdebug or var_dump to show full object/array with PHP.

How to get xdebug or var_dump to show full object/array with PHP?

To get xdebug or var_dump to show full object/array with PHP, we can set a few settings in php.ini or use the ini_set function.

For instance, we write

xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024 

in php.ini to show the object or array up to the given depth, number of children, and max amount of data in bytes respectively.

We can set them all to -1 if we want to display everything without limit.

If we want to set the settings at runtime, then we call ini_set by writing

ini_set('xdebug.var_display_max_depth', 10);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);

to set the same options.

Conclusion

To get xdebug or var_dump to show full object/array with PHP, we can set a few settings in php.ini or use the ini_set function.

Leave a Reply

Your email address will not be published.