# BaseVarDumper

> BaseVarDumper provides concrete implementation for yii\helpers\VarDumper.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [helpers](/docs/api/yii/helpers/index.md) › BaseVarDumper

| class | `yii\helpers\BaseVarDumper` |
| --- | --- |
| Since | 2.0 |
| Source | [`framework/helpers/BaseVarDumper.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/helpers/BaseVarDumper.php#L22) |

1 subclass:

- [`VarDumper`](/docs/api/yii/helpers/vardumper/index.md)

BaseVarDumper provides concrete implementation for [`VarDumper`](/docs/api/yii/helpers/vardumper/index.md).

Do not use BaseVarDumper. Use [`VarDumper`](/docs/api/yii/helpers/vardumper/index.md) instead.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`dump()`](#method-dump) static | Displays a variable. | `BaseVarDumper` |
| [`dumpAsString()`](#method-dumpAsString) static | Dumps a variable in terms of a string. | `BaseVarDumper` |
| [`export()`](#method-export) static | Exports a variable as a string representation. | `BaseVarDumper` |

## Method details

### dump() <span id="method-dump"></span>

```php
public static function dump(mixed $var, int $depth = 10, bool $highlight = false): mixed
```

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.

**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() <span id="method-dumpAsString"></span>

```php
public static function dumpAsString(mixed $var, int $depth = 10, bool $highlight = false): string
```

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.

**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() <span id="method-export"></span>

```php
public static function export(mixed $var): string
```

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.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$var` | `mixed` | The variable to be exported. |

**Returns**

`string`: A string representation of the variable