How to print out value on controller Laravel?
You can Use these several methods for printing in Laravel.
1. dump($var)
2. dd($id)
3. var_dump($var)
4. die($var)
5. print_r($var)
dd($var)
is great because it stops the program after it runs so by moving it around you get a good sense of which line of code is causing an error.
In Laravel use dd($id)
or if you don't want to halt the execution, you can use dump($var)
.
You can still always use PHP's native functions like var_dump
, die
and print_r
.