phpDocumentor Smarty
plugins
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file modifier.debug_print_var.php

Documentation is available at modifier.debug_print_var.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8.  
  9. /**
  10.  * Smarty debug_print_var modifier plugin
  11.  *
  12.  * Type:     modifier<br>
  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.  * @param array|object 
  18.  * @param integer 
  19.  * @param integer 
  20.  * @return string 
  21.  */
  22. function smarty_modifier_debug_print_var($var$depth 0$length 40)
  23. {
  24.     $_replace array("\n"=>'<i>&#92;n</i>'"\r"=>'<i>&#92;r</i>'"\t"=>'<i>&#92;t</i>');
  25.     if (is_array($var)) {
  26.         $results "<b>Array (".count($var).")</b>";
  27.         foreach ($var as $curr_key => $curr_val{
  28.             $return smarty_modifier_debug_print_var($curr_val$depth+1$length);
  29.             $results .= "<br>".str_repeat('&nbsp;'$depth*2)."<b>".strtr($curr_key$_replace)."</b> =&gt$return";
  30.         }
  31.         return $results;
  32.     else if (is_object($var)) {
  33.         $object_vars get_object_vars($var);
  34.         $results "<b>".get_class($var)." Object (".count($object_vars).")</b>";
  35.         foreach ($object_vars as $curr_key => $curr_val{
  36.             $return smarty_modifier_debug_print_var($curr_val$depth+1$length);
  37.             $results .= "<br>".str_repeat('&nbsp;'$depth*2)."<b>$curr_key</b> =&gt$return";
  38.         }
  39.         return $results;
  40.     else {
  41.         if (empty($var&& $var != "0"{
  42.             return '<i>empty</i>';
  43.         }
  44.         if (strlen($var$length {
  45.             $results substr($var0$length-3).'...';
  46.         else {
  47.             $results $var;
  48.         }
  49.         $results htmlspecialchars($results);
  50.         $results strtr($results$_replace);
  51.         return $results;
  52.     }
  53. }
  54.  
  55. /* vim: set expandtab: */
  56.  
  57. ?>

Documentation generated on Tue, 24 Oct 2006 09:24:01 -0500 by phpDocumentor 1.3.1