|
|
|
<?
/*
* string dump ( mixed $var )
*
* returns a string containing a HTML-table representation of $var
*
* (c) 2001-2002 Daniel Jaenecke < jaenecke[AT]gmx[DOT]li
*
* published under the terms of the Gnu Pblic License
* [ http://www.gnu.org/copyleft/gpl.html#SEC1 ]
*
* have fun
*/
function dump ( $var ) {
/*
* patterns for output
* customize these to change reperesentation of data
*/
$pattern_key = '<td><b>%s</b></td>';
$pattern_type = '<td><i>%s</i></td>';
$pattern_value = '<td>%s</td>';
/*
* handling non-arrays
*/
if ( !is_array ( $var ) ) {
switch ( gettype ( $var ) ) {
case 'string':
if ( empty ( $var ) ) {
return ' ';
}
else {
return sprintf ( '<code>%s</code>',
htmlentities ( $var ) );
}
break; // string
case 'boolean':
if ( $var ) {
return '<i>true</i>';
}
else {
return '<i>false</i>';
}
break; // boolean
case 'object':
return dump ( array (
'class' => get_class ( $var ),
'parent_class' => get_parent_class ( $var ),
'methods'=>get_class_methods ( get_class (
$var ) ),
'attributes' => get_object_vars ( $var )
) );
break; // object
case 'resource':
return sprintf ( '%s (%s)', $var, get_resource_type
( $var ) );
break; // resource
default:
return $var;
break; // default
} // switch gettype ( value )
} // !is_array
/*
* generate output
*/
$out = '<table cellspacing="0" cellpadding="1" border="1">';
foreach ( $var as $key => $value ) {
// get type of current value
$type = substr ( gettype ( $var[ $key ] ), 0, 3 );
// determine size of value if available
if ( $type == 'arr' )
$type .= sprintf ( '(%s)', sizeof ( $var[ $key ] ) );
elseif ( $type == 'str' )
$type .= sprintf ( '(%s)', strlen ( $var[ $key ] ) );
$out .= sprintf (
'<tr>' .
$pattern_key .
$pattern_type .
$pattern_value .
'</tr>',
$key, $type, dump ( $value )
);
} // foreach
$out .= '</table>';
return $out;
} // function dump ()
?> |
|
| The class to check load time of your script
VERY usefull for relatively slow applications, but not only.. Categories : PHP, PHP Classes, Debugging | | | PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP | | | Function to check connection to MySQL and redirect to an error page if an error occurs Categories : MySQL, PHP, Debugging, Databases | | | Display variables when a form is submitted using POST/GET Categories : PHP, Functions, Variables, Debugging | | | PHPLinkRot v1.0 - program which allows users to report broken links on
your website just by clicking a button. Works well on custom 404 pages Categories : PHP, Complete Programs, Debugging, URLs, Site Planning | | | A time measuring and performance benchmarking class Categories : PHP, PHP Classes, Testing, Debugging, Date Time | | | phpDocumentor 1.1.0 - automatic documentation tool for PHP. Generates API documentation in HTML, PDF, and CHM formats with automatic linking, smart inheritance and packaging, very fast and stable. Official website
http://www.phpdoc.org Categories : Complete Programs, Debugging, PHP, Documentation | | | Newbie Notes #4 - Trapping dumb MySQL query errors Categories : PHP, Databases, MySQL, Debugging, Beginner Guides | | | Newbie Notes #3 - What went wrong? A useful little debugging aid Categories : PHP, Beginner Guides, Debugging | | | An email validation script that actually checks against the recipient's mail server. Categories : Email, Complete Programs, PHP, Network, Debugging | | | Custom error messages. Categories : PHP, Debugging | | | Memory Growth, Memory Leaks, Garbage Collection. Categories : Debugging, PHP | | | A Custom Error Handling And Debugging Class Categories : PHP, PHP Classes, Debugging, Errors and Logging | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Example of function to send out email if error occurs Categories : PHP, Email, Debugging, Errors and Logging | |
|
|
|