| [ Index ] |
krapohl.info |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * Smarty plugin 5 * ------------------------------------------------------------- 6 * Type: modifier 7 * Name: debug_print_var 8 * Purpose: formats variable contents for display in the console 9 * ------------------------------------------------------------- 10 */ 11 function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) 12 { 13 if (is_array($var)) { 14 $results = "<b>Array (".count($var).")</b>"; 15 foreach ($var as $curr_key => $curr_val) { 16 $return = smarty_modifier_debug_print_var($curr_val, $depth+1); 17 $results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return"; 18 } 19 return $results; 20 } else if (is_object($var)) { 21 $object_vars = get_object_vars($var); 22 $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>"; 23 foreach ($object_vars as $curr_key => $curr_val) { 24 $return = smarty_modifier_debug_print_var($curr_val, $depth+1); 25 $results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return"; 26 } 27 return $results; 28 } else { 29 if (empty($var) && $var != "0") { 30 return '<i>empty</i>'; 31 } 32 if (strlen($var) > $length ) { 33 $results = substr($var, 0, $length-3).'...'; 34 } else { 35 $results = $var; 36 } 37 $results = preg_replace("![\r\t\n]!", " ", $results); 38 $results = htmlspecialchars(htmlspecialchars($results)); 39 return $results; 40 } 41 } 42 43 /* vim: set expandtab: */ 44 45 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 16 22:40:07 2005 | Cross-referenced by PHPXref 0.6 |