0 follower

Class yii\helpers\BaseVarDumper

Inheritanceyii\helpers\BaseVarDumper
Subclassesyii\helpers\VarDumper
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/helpers/BaseVarDumper.php

BaseVarDumper provides concrete implementation for yii\helpers\VarDumper.

Do not use BaseVarDumper. Use yii\helpers\VarDumper instead.

Public Methods

Hide inherited methods

Method Description Defined By
dump() Displays a variable. yii\helpers\BaseVarDumper
dumpAsString() Dumps a variable in terms of a string. yii\helpers\BaseVarDumper
export() Exports a variable as a string representation. yii\helpers\BaseVarDumper

Method Details

Hide inherited methods

dump() public static method

Displays a variable.

This method achieves the similar functionality as var_dump and print_r but is more robust when handling complex objects such as Yii controllers.

public static void dump ( $var, $depth 10, $highlight false )
$var mixed

Variable to be dumped

$depth integer

Maximum depth that the dumper should go into the variable. Defaults to 10.

$highlight boolean

Whether the result should be syntax-highlighted

                public static function dump($var, $depth = 10, $highlight = false)
{
    echo static::dumpAsString($var, $depth, $highlight);
}

            
dumpAsString() public static method

Dumps a variable in terms of a string.

This method achieves the similar functionality as var_dump and print_r but is more robust when handling complex objects such as Yii controllers.

public static string dumpAsString ( $var, $depth 10, $highlight false )
$var mixed

Variable to be dumped

$depth integer

Maximum depth that the dumper should go into the variable. Defaults to 10.

$highlight boolean

Whether the result should be syntax-highlighted

return string

The string representation of the variable

                public static function dumpAsString($var, $depth = 10, $highlight = false)
{
    self::$_output = '';
    self::$_objects = [];
    self::$_depth = $depth;
    self::dumpInternal($var, 0);
    if ($highlight) {
        $result = highlight_string("<?php\n" . self::$_output, true);
        self::$_output = preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
    }
    return self::$_output;
}

            
export() public static method

Exports a variable as a string representation.

The string is a valid PHP expression that can be evaluated by PHP parser and the evaluation result will give back the variable value.

This method is similar to var_export(). The main difference is that it generates more compact string representation using short array syntax.

It also handles objects by using the PHP functions serialize() and unserialize().

PHP 5.4 or above is required to parse the exported value.

public static string export ( $var )
$var mixed

The variable to be exported.

return string

A string representation of the variable

                public static function export($var)
{
    self::$_output = '';
    self::exportInternal($var, 0);
    return self::$_output;
}