April 22, 2018 —John Koster
The dd
method will dump the contents of the collection and stop execution of the script; in this way, it works just like the global dd
helper function except that it acts exclusively on the collections internal array.
1public function dd(2 ...$args3);
In the following example, we will create a collection and dump its content to the screen and stop execution of the script. The last echo
statement should not be visible in the browser or terminal output:
1$collection = collect([2 'key' => 'value'3]);4 5$collection->dd();6 7echo 'This should not be visible in the output';
If viewed in a browser, the previous example would output:
1array:1 [2 "key" => "value"3]
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.