/[cvs]/nfo/php/libs/net.php.smarty/plugins/modifier.debug_print_var.php
ViewVC logotype

Contents of /nfo/php/libs/net.php.smarty/plugins/modifier.debug_print_var.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Oct 9 00:53:36 2002 UTC (21 years, 10 months ago) by cvsjoko
Branch: MAIN
no message

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('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $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('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $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 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed