DEV Community

Discussion on: Using dd (dump and die) function in PHP

Collapse
 
he110 profile image
Elijah Zobenko • Edited

A very handy thing!
I would suggest two things:

  • You can extend the argument list to make it support an unlimited amount of data passed
// three dots before $additional are important
function dd($data, ...$additional): void
{
    echo '<pre>';
    var_dump($data, $additional);
    echo '</pre>';
    die;
}

dd('test', ['another' => 'test'], null, false, 123);
Enter fullscreen mode Exit fullscreen mode
  • There is an amazing library called var-dumper. It makes the similar thing, but supports cli mode