BaseVarDumper
API reference › yii › helpers › BaseVarDumper
1 subclass
BaseVarDumper provides concrete implementation for VarDumper.
Do not use BaseVarDumper. Use VarDumper instead.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
dump() static | Displays a variable. | BaseVarDumper |
dumpAsString() static | Dumps a variable in terms of a string. | BaseVarDumper |
export() static | Exports a variable as a string representation. | BaseVarDumper |
Method details
Section titled “Method details”dump()
Section titled “dump() ”public static function dump(mixed $var, int $depth = 10, bool $highlight = false): mixedDisplays 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.
Parameters
| Parameter | Type | Description |
|---|---|---|
$var | mixed | Variable to be dumped |
$depth | int | Maximum depth that the dumper should go into the variable. Defaults to 10. |
$highlight | bool | Whether the result should be syntax-highlighted |
Returns
mixed
dumpAsString()
Section titled “dumpAsString() ”public static function dumpAsString(mixed $var, int $depth = 10, bool $highlight = false): stringDumps 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.
Parameters
| Parameter | Type | Description |
|---|---|---|
$var | mixed | Variable to be dumped |
$depth | int | Maximum depth that the dumper should go into the variable. Defaults to 10. |
$highlight | bool | Whether the result should be syntax-highlighted |
Returns
string: The string representation of the variable
export()
Section titled “export() ”public static function export(mixed $var): stringExports 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.
Parameters
| Parameter | Type | Description |
|---|---|---|
$var | mixed | The variable to be exported. |
Returns
string: A string representation of the variable