Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using dd() function in Laravel

Tags:

laravel

dump

While using dd() function in Laravel, if my output looks like this,

Collection {#194 ▼
  #items: array:3 [▼
    0 => Post {#195 ▶}
    1 => Post {#196 ▶}
    2 => Post {#197 ▶}
  ]
}

what are the meanings of the codes, such as #194, #195, etc? Are they helpful in any way?

like image 411
code_locked Avatar asked Sep 19 '18 11:09

code_locked


1 Answers

According to VarDumper documentation - that's what dd() uses behind the hood:

#14 is the internal object handle. It allows comparing two consecutive dumps of the same object. 

Depending on whether the item being dumped is an object or PHP resource, you'll see # for objects and @ for resources in there. The number you're seeing after # is the ID assigned by the VarDumper to that object. It's displayed so that you can easily identify dumps for the same object, if you dump it multiple times.

like image 123
jedrzej.kurylo Avatar answered Sep 28 '22 12:09

jedrzej.kurylo