/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ public static function dump($data) { // disabled ? if (!APrint::_debug()) { return false; } // Begin Output Buffering ob_start(); // more arguments ? if (func_num_args() > 1) { $_ = func_get_args(); foreach ($_ as $d) { echo APrint::dump($d); } return ob_get_clean(); } // the js? echo APrint::_js(); // find caller $_ = debug_backtrace(); while ($d = array_pop($_)) { if (strtolower(@$d['function']) == 'aprint' || isset($d['class']) && strtolower(@$d['class']) == 'aprint') { break; } } // the content echo ' <div class="aprint-root"> <ul class="aprint-node aprint-first">'; APrint::_dump($data); echo ' <li class="aprint-footnote">'; if (isset($d['file'])) { echo ' <span class="aprint-call">Called from <code>' . str_replace(ROSTER_BASE, '', $d['file']) . '</code>, line <code>' . $d['line'] . '</code></span>'; } echo ' </li> </ul> </div>'; // flee the hive $_recursion_marker = APrint::_marker(); if ($hive =& APrint::_hive($dummy)) { foreach ($hive as $i => $bee) { if (is_object($bee)) { unset($hive[$i]->{$_recursion_marker}); } else { unset($hive[$i][$_recursion_marker]); } } } // End Output Buffering return ob_get_clean(); }
/** * Wrapper for debugging function dumps arrays/object formatted * * @param array $arr * @param string $prefix * @return string */ function aprint($arr, $prefix = '', $return = false) { if ($return) { return APrint::dump($arr); } else { echo APrint::dump($arr); } }