10
* Smarty debug_print_var modifier plugin
13
* Name: debug_print_var<br>
14
* Purpose: formats variable contents for display in the console
15
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
16
* debug_print_var (Smarty online manual)
17
* @author Monte Ohrt <monte at ohrt dot com>
23
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
31
switch (gettype($var)) {
33
$results = '<b>Array (' . count($var) . ')</b>';
34
foreach ($var as $curr_key => $curr_val) {
35
$results .= '<br>' . str_repeat(' ', $depth * 2)
36
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
37
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
42
$object_vars = get_object_vars($var);
43
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
44
foreach ($object_vars as $curr_key => $curr_val) {
45
$results .= '<br>' . str_repeat(' ', $depth * 2)
46
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
47
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
56
} elseif (false === $var) {
58
} elseif (null === $var) {
61
$results = htmlspecialchars((string) $var);
63
$results = '<i>' . $results . '</i>';
67
$results = htmlspecialchars((string) $var);
70
$results = strtr($var, $_replace);
71
if (strlen($var) > $length ) {
72
$results = substr($var, 0, $length - 3) . '...';
74
$results = htmlspecialchars('"' . $results . '"');
78
$results = strtr((string) $var, $_replace);
79
if (strlen($results) > $length ) {
80
$results = substr($results, 0, $length - 3) . '...';
82
$results = htmlspecialchars($results);
88
/* vim: set expandtab: */