Skip to content
Advertisement

Make var_dump look pretty

I have a simple $_GET[] query var set for showing testing data when pulling down queries from the DB.

JavaScript

When I do var_dump, as expected it’s this big array string that is all smushed together. Is there a way to add in line breaks at least for this or display the var_dump in a way that’s more readable? I’m open to jQuery suggestions on manipulating the string after it’s posted.

Advertisement

Answer

I really love var_export(). If you like copy/paste-able code, try:

JavaScript

Or even something like this for color syntax highlighting:

JavaScript

You can do the same with print_r(). For var_dump() you would just need to add the <pre> tags:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement