WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : dump v0.3 - use this to create a HTML table representation of any kind of variable
Categories : Debugging, PHP Update Picture
Daniel Jaenecke
Date : Jul 26th 2002
Grade : 2 of 5 (graded 2 times)
Viewed : 3445
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Daniel Jaenecke
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?

/*
* 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