XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
modifier.debug_print_var.php
Go to the documentation of this file.
1 <?php
26 function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
27 {
28  $_replace = array("\n"=>'<i>&#92;n</i>', "\r"=>'<i>&#92;r</i>', "\t"=>'<i>&#92;t</i>');
29  if (is_array($var)) {
30  $results = "<b>Array (" . count($var) . ")</b>";
31  foreach ($var as $curr_key => $curr_val) {
32  $return = smarty_modifier_debug_print_var($curr_val, $depth + 1, $length);
33  $results .= "<br>" . str_repeat('&nbsp;', $depth * 2) . "<b>" . strtr($curr_key, $_replace) . "</b> =&gt; {$return}";
34  }
35  } else if (is_object($var)) {
36  $object_vars = get_object_vars($var);
37  $results = "<b>" . get_class($var) . " Object (" . count($object_vars) . ")</b>";
38  foreach ($object_vars as $curr_key => $curr_val) {
39  if (is_object($curr_val)) {
40  $return ='[object ' . get_class($curr_val) . ']';
41  } else {
42  $return = smarty_modifier_debug_print_var($curr_val, $depth + 1, $length);
43  }
44  $results .= "<br>" . str_repeat('&nbsp;', $depth * 2) . "<b>{$curr_key}</b> =&gt; {$return}";
45  }
46  } else if (is_resource($var)) {
47  $results = '<i>' . (string)$var . '</i>';
48  } else if (empty($var) && $var != "0") {
49  $results = '<i>empty</i>';
50  } else {
51  if (strlen($var) > $length) {
52  $results = substr($var, 0, $length - 3) . '...';
53  } else {
54  $results = $var;
55  }
56  $results = htmlspecialchars($results);
57  $results = strtr($results, $_replace);
58  }
59  return $results;
60 }
61 
62 /* vim: set expandtab: */
63 
64 ?>