00001 <?php 00023 function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) 00024 { 00025 $_replace = array( 00026 "\n" => '<i>\n</i>', 00027 "\r" => '<i>\r</i>', 00028 "\t" => '<i>\t</i>' 00029 ); 00030 00031 switch (gettype($var)) { 00032 case 'array' : 00033 $results = '<b>Array (' . count($var) . ')</b>'; 00034 foreach ($var as $curr_key => $curr_val) { 00035 $results .= '<br>' . str_repeat(' ', $depth * 2) 00036 . '<b>' . strtr($curr_key, $_replace) . '</b> => ' 00037 . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 00038 $depth--; 00039 } 00040 break; 00041 case 'object' : 00042 $object_vars = get_object_vars($var); 00043 $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; 00044 foreach ($object_vars as $curr_key => $curr_val) { 00045 $results .= '<br>' . str_repeat(' ', $depth * 2) 00046 . '<b> ->' . strtr($curr_key, $_replace) . '</b> = ' 00047 . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 00048 $depth--; 00049 } 00050 break; 00051 case 'boolean' : 00052 case 'NULL' : 00053 case 'resource' : 00054 if (true === $var) { 00055 $results = 'true'; 00056 } elseif (false === $var) { 00057 $results = 'false'; 00058 } elseif (null === $var) { 00059 $results = 'null'; 00060 } else { 00061 $results = htmlspecialchars((string) $var); 00062 } 00063 $results = '<i>' . $results . '</i>'; 00064 break; 00065 case 'integer' : 00066 case 'float' : 00067 $results = htmlspecialchars((string) $var); 00068 break; 00069 case 'string' : 00070 $results = strtr($var, $_replace); 00071 if (strlen($var) > $length ) { 00072 $results = substr($var, 0, $length - 3) . '...'; 00073 } 00074 $results = htmlspecialchars('"' . $results . '"'); 00075 break; 00076 case 'unknown type' : 00077 default : 00078 $results = strtr((string) $var, $_replace); 00079 if (strlen($results) > $length ) { 00080 $results = substr($results, 0, $length - 3) . '...'; 00081 } 00082 $results = htmlspecialchars($results); 00083 } 00084 00085 return $results; 00086 } 00087 00088 /* vim: set expandtab: */ 00089 00090 ?>
| Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|
