src/Util.php
public static function dump( $var, $format = 'html', $back = 0, $options = NULL, $return = FALSE, $max_depth = 6 )
    {
        list( $file, $line ) = self::caller( $back );

        if ( !$options ){
            $options = array();
        }
        $default_options = array(
                'title' => 'system dump',
                'font_size' => 11,
                'max_string_length' => self::DUMP_MAX_LENGTH,
                'type' => 'textarea',
            );
        $options = array_merge( $default_options, $options );

        $title             = $options['title'];
        $font_size         = $options['font_size'];
        $max_string_length = $options['max_string_length'];
        $type              = $options['type'];

        $lines = array();
        $recursion = array();
        self::_dump( '-', $var, 0, $max_string_length, $lines, $max_depth, $recursion );

        switch( $format )
        {
        case "html":
            switch( $type ){
            case 'div':
                $output  = "<div style=\"font-size:12px; margin: 2px\"> $title:" . implode('',$lines) . " @$file($line)</div>";
                break;
            case 'textarea':
            default:
                $output  = "<h3 style=\"font-size:12px; margin: 0; color:black; background-color:white; text-align: left\"> $title @$file($line)</h3>";
                $output .= "<textarea rows=14 style=\"width:100%; font-size:{$font_size}px; margin: 0; color:black; background-color:white; border: 1px solid silver;\">";
                $output .= implode(PHP_EOL,$lines);
                $output .= "</textarea>";
                break;
            }
            break;
        case "shell":
        default:
            $output  = "$title @$file($line)" . PHP_EOL;
            $output .= implode(PHP_EOL,$lines) . PHP_EOL;
            break;
        }

        if ( $return ){
            return $output;
        }
        else{
            echo $output;
            return null;
        }
    }
public static function dump( $var, $format = 'html', $back = 0, $options = NULL, $return = FALSE, $max_depth = 6 )
    {
        list( $file, $line ) = self::caller( $back );

        if ( !$options ){
            $options = array();
        }
        $default_options = array(
                'title' => 'system dump',
                'font_size' => 11,
                'max_string_length' => self::DUMP_MAX_LENGTH,
                'type' => 'textarea',
            );
        $options = array_merge( $default_options, $options );

        $title             = $options['title'];
        $font_size         = $options['font_size'];
        $max_string_length = $options['max_string_length'];
        $type              = $options['type'];

        $lines = array();
        $recursion = array();
        self::_dump( '-', $var, 0, $max_string_length, $lines, $max_depth, $recursion );

        switch( $format )
        {
        case "html":
            switch( $type ){
            case 'div':
                $output  = "<div style=\"font-size:12px; margin: 2px\"> $title:" . implode('',$lines) . " @$file($line)</div>";
                break;
            case 'textarea':
            default:
                $output  = "<h3 style=\"font-size:12px; margin: 0; color:black; background-color:white; text-align: left\"> $title @$file($line)</h3>";
                $output .= "<textarea rows=14 style=\"width:100%; font-size:{$font_size}px; margin: 0; color:black; background-color:white; border: 1px solid silver;\">";
                $output .= implode(PHP_EOL,$lines);
                $output .= "</textarea>";
                break;
            }
            break;
        case "shell":
        default:
            $output  = "$title @$file($line)" . PHP_EOL;
            $output .= implode(PHP_EOL,$lines) . PHP_EOL;
            break;
        }

        if ( $return ){
            return $output;
        }
        else{
            echo $output;
            return null;
        }
    }
public static function dump ( $ var , $ format = 'html' , $ back = 0 , $ options = NULL , $ return = FALSE , $ max_depth = 6 ) { list ( $ file , $ line ) = self :: caller ( $ back ) ; if ( ! $ options ) { $ options = array ( ) ; } $ default_options = array ( 'title' => 'system dump' , 'font_size' => 11 , 'max_string_length' => self :: DUMP_MAX_LENGTH , 'type' => 'textarea' , ) ; $ options = array_merge ( $ default_options , $ options ) ; $ title = $ options [ 'title' ] ; $ font_size = $ options [ 'font_size' ] ; $ max_string_length = $ options [ 'max_string_length' ] ; $ type = $ options [ 'type' ] ; $ lines = array ( ) ; $ recursion = array ( ) ; self :: _dump ( '-' , $ var , 0 , $ max_string_length , $ lines , $ max_depth , $ recursion ) ; switch ( $ format ) { case "html" : switch ( $ type ) { case 'div' : $ output = "<div style=\"font-size:12px; margin: 2px\"> $title:" . implode ( '' , $ lines ) . " @$file($line)</div>" ; break ; case 'textarea' : default : $ output = "<h3 style=\"font-size:12px; margin: 0; color:black; background-color:white; text-align: left\"> $title @$file($line)</h3>" ; $ output .= "<textarea rows=14 style=\"width:100%; font-size:{$font_size}px; margin: 0; color:black; background-color:white; border: 1px solid silver;\">" ; $ output .= implode ( PHP_EOL , $ lines ) ; $ output .= "</textarea>" ; break ; } break ; case "shell" : default : $ output = "$title @$file($line)" . PHP_EOL ; $ output .= implode ( PHP_EOL , $ lines ) . PHP_EOL ; break ; } if ( $ return ) { return $ output ; } else { echo $ output ; return null ; } }
dump a variable

@param mixed $var
@param string $format
@param int $back
@param array $options
@param bool $return
@param int $max_depth

@return string
dump a variable