By 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.
#Signature
1public function dd(
2 ...$args
3);
#Example Use
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]
∎