Skip to content

Instantly share code, notes, and snippets.

@tomsseisums
Last active December 14, 2015 23:49
Show Gist options
  • Save tomsseisums/5168218 to your computer and use it in GitHub Desktop.
Save tomsseisums/5168218 to your computer and use it in GitHub Desktop.
`dump()` is a debugging helper that mimics the output of `var_dump()` wrapped in `<pre/>` and then returned as a string. I made the function because I hate that var_dump() echoes directly and may consume the overall page style. This gives me the good old var_dump() which I can then pass directly into my logging mechanisms, or even pass to backed…
<?php
/**
* Returns a string containing var_dump() for each argument wrapped in a <pre>
*
* @author joltmode
* @return string
*/
function dump()
{
$arguments = func_get_args();
ob_start();
foreach ($arguments as $argument) var_dump( $argument );
return '<pre>' . ob_get_clean() . '</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment