5 * -------------------------------------------------------------
7 * Name: debug_print_var
8 * Purpose: formats variable contents for display in the console
9 * -------------------------------------------------------------
11 function tpl_modifier_debug_print_var($var, $depth = 0, $length = 40)
15 $results = "<b>Array (".count($var).")</b>";
16 foreach ($var as $curr_key => $curr_val)
18 $return = tpl_modifier_debug_print_var($curr_val, $depth+
1, $length);
19 $results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return";
23 else if (is_object($var))
25 $object_vars = get_object_vars($var);
26 $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
27 foreach ($object_vars as $curr_key => $curr_val)
29 $return = tpl_modifier_debug_print_var($curr_val, $depth+
1, $length);
30 $results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return";
36 if (empty($var) && $var != "0")
38 return '<i>empty</i>';
40 if (strlen($var) > $length )
42 $results = substr($var, 0, $length-3).'...';
48 $results = preg_replace("![\r\t\n]!", " ", $results);
49 $results = htmlspecialchars($results);