Improved var_dump() with colored output

As developers, we all do some debugging within the code that we are writing at that moment. Usually the first choice is either calling var_dump or print_r depending on what we are used to but it usually ends the same way:

  1. print '<pre>';
  2. var_dump($something);
  3. // or print_r($something);

Usually the <pre> tag is not even included due to us being lazy and we end up viewing the source because the output that we got in Times New Roman is not really that readable.

Of course, there is Xdebug which we can used but not all of us have control over our webservers or desire to install/enable any extensions.

Here is a class, which you will be able to use in all those occasions.

It could as well be considered an improvement over the class mentioned in one of my previous articles however this class does not change the format of the output, only its colors.

Improved Zend_Debug::dump() and var_dump() functions

The native Zend_Debug::dump() function is a step forward from the usual approach to dumping variables to debug your code (usually by using var_dump or print_r). However, as always, things can be improved and that is what we will try to do in this article.

Showing 1 - 2 of 2 results