public function VarDumper::export in Devel 4.x
Same name and namespace in other branches
- 8.3 src/Plugin/Devel/Dumper/VarDumper.php \Drupal\devel\Plugin\Devel\Dumper\VarDumper::export()
- 8 src/Plugin/Devel/Dumper/VarDumper.php \Drupal\devel\Plugin\Devel\Dumper\VarDumper::export()
- 8.2 src/Plugin/Devel/Dumper/VarDumper.php \Drupal\devel\Plugin\Devel\Dumper\VarDumper::export()
Returns a string representation of a variable.
Parameters
mixed $input: The variable to export.
string $name: (optional) The label to output before variable, defaults to NULL.
Return value
string String representation of a variable.
Overrides DevelDumperInterface::export
File
- src/
Plugin/ Devel/ Dumper/ VarDumper.php, line 24
Class
- VarDumper
- Provides a Symfony VarDumper dumper plugin.
Namespace
Drupal\devel\Plugin\Devel\DumperCode
public function export($input, $name = NULL) {
$cloner = new VarCloner();
$dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
$output = fopen('php://memory', 'r+b');
$dumper
->dump($cloner
->cloneVar($input), $output);
$output = stream_get_contents($output, -1, 0);
if ($name) {
$output = $name . ' => ' . $output;
}
return $this
->setSafeMarkup($output);
}