How to write own DD() function same as laravel?

To create your own version of the Laravel DD() function, you can create a new function in your codebase and have it take in any number of arguments. Inside the function, you can use the built-in PHP functions "var_dump()" or "print_r()" to output the values of the arguments, and then use "exit()" to stop the execution of the script. Here's an example of what the function might look like:

<?php

function DD()
{
  foreach (func_get_args() as $arg) {
    var_dump($arg);
  }
  exit();
}

Watch a course Learn object oriented PHP

You can call this function with any number of arguments, just like the Laravel DD() function.

<?php

function DD()
{
  foreach (func_get_args() as $arg) {
    var_dump($arg);
  }
  exit();
}

DD("Hello World!", 123, ["a", "b", "c"]);

Note: Laravel DD() function is a combination of dump and die so it will stop the execution of script after displaying the variable but in this code it will not stop the execution of script.