Contents of objects in the debug window (now with attatchment included)
| From: | Martijn van Zal | Date: | Wed, 05 Jun 2002 15:57:39 +0000 |
| Subject: | Contents of objects in the debug window (now with attatchment included) | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-118@lists.php.net to get a copy of this message | ||
Whoops again... (shame shame shame) now with attatchment included....
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: debug_print_var
* Purpose: formats variable contents for display in the console
* -------------------------------------------------------------
*/
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40, $printObjects = true)
{
if (is_array($var)) {
$results = "<b>Array (".count($var).")</b>";
foreach ($var as $curr_key => $curr_val) {
$return = smarty_modifier_debug_print_var($curr_val, $depth+1);
$results .= '<br>\r'.str_repeat(' ',
$depth*2)."<b>$curr_key</b> => $return";
}
return $results;
} /* MvZ: started adding here */ else if (is_object($var)) {
$results = "<b>Object (".get_class($var) . (get_parent_class($var)?" ->
".get_parent_class($var):"").") </b>";
$array = get_object_vars($var);
foreach ($array as $curr_key => $curr_val) {
$return = "";
if ($printObjects) {
$return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length, false);
$results .= '<br>\r'.str_repeat(' ',
$depth*2)."<b>$curr_key</b> => $return";
}
}
return $results;
} /* MvZ: ended adding here */ else {
if (empty($var) && $var != "0") {
return '<i>empty</i>';
}
if (strlen($var) > $length ) {
$results = substr($var, 0, $length-3).'...';
} else {
$results = $var;
}
$results = preg_replace("![\r\t\n]!", " ", $results);
}
$results = htmlspecialchars(htmlspecialchars($results));
return $results;
}
/* vim: set expandtab: */
?>
________________________________________
Martijn van Zal GFXartist Network
Technical Manager
mail: martijn@gfxartist.com
icq: 8213621