Search code examples
laraveldump

Using dd() function in Laravel


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?


Solution

  • 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.