[英]How to get exact property meant by infamous “trying to get property of non-object” error message?
Laravel 5 gives out this exact error message every time an unknown property is used somewhere in a view, it's probably one of the most seen error messages ever: 每当在视图中的某处使用未知属性时,Laravel 5都会给出此确切的错误消息,这可能是有史以来最常见的错误消息之一:
trying to get property of non-object
The Problem: Laravel does NEVER say which property of which object . 问题: Laravel从未说过哪个对象的 哪个属性 。 This is insane!
疯了吧! Even plain PHP clearly says the exact point of failure, but Laravel does not.
甚至普通的PHP都清楚地指出了确切的故障点,但是Laravel却没有。
So the question is, how to find out the exact object/property behind this error ? 所以问题是,如何找出此错误背后的确切对象/属性?
Laravel does NEVER say you this, but You can use dd()
in the view multiple time at different step. Laravel从来不会这样说,但是您可以在视图的不同步骤多次使用
dd()
。 So, you can get where was the problem. 因此,您可以找到问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.