dd() vs var_dump() vs dump() vs print_r() in Laravel

Besides dump functions PHP provides, Laravel brings new functions which help developers debug variables. They are dd() and dump().

Table of Contents


dd is shorthand for Dump and Die. The function dumps the variable’s content to the web browser. Unlike other functions, dd() stops the execution of scripts below it.

dd('this is a string');

The output of the first line:

The output of the 2nd line:


dump() is similar to dd() but allows the below script to be executed.

$tools = [
            'Hammer', 'Screwdrivers', 'Wrench', 'Tape'
echo 'This is another line';

As you see, the string after the dump can be printed out on the screen.


This PHP function shows structured information about variables, including their data types and values.

$user = Auth::user();


The method prints human-readable information about a variable.

$car_brands = ['Fiat', 'Nissan', 'Toyota', 'Tesla', 'Chevrolet', 'Huyndai'];

Array ( [0] => Fiat [1] => Nissan [2] => Toyota [3] => Tesla [4] => Chevrolet [5] => Huyndai )

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.