在Laravel中使用dd()函数

5
在Laravel中使用dd()函数时,如果我的输出看起来像这样:
Collection {#194 ▼
  #items: array:3 [▼
    0 => Post {#195 ▶}
    1 => Post {#196 ▶}
    2 => Post {#197 ▶}
  ]
}

这些代码,例如#194、#195等,有什么含义?它们有助于什么方面的工作吗?


我从未注意到,好问题,但直到现在对我没有用处。 - syam
或者你可以使用 print_r(),像这样(即 print('<pre style="color:red;">'); print_r($rslt); print('</pre>'); exit; - user10186369
6
#194和#195是对象中的关键部分。https://dev59.com/tFkT5IYBdhLWcg3wIsOw - Anandu Krishna
1个回答

7
根据VarDumper文档 - 这就是dd()在后台使用的内容:
#14 is the internal object handle. It allows comparing two consecutive dumps of the same object. 

根据被转储的项是对象还是PHP资源,您将看到其中#用于对象@用于资源。在#后面看到的数字是VarDumper分配给该对象的ID。它被显示出来,以便您可以轻松地识别同一对象的多次转储。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接