你在Laravel 工作时见过这个可爱的错误吗?
Method Illuminate\View\View::__toString() must not throw an exception
我看过了,非常烦人.我发现了抛出此错误的两个原因.我只是想帮助人们不用花上一小时又一小时的时间.
查看答案&;以下情况:)
你在Laravel 工作时见过这个可爱的错误吗?
Method Illuminate\View\View::__toString() must not throw an exception
我看过了,非常烦人.我发现了抛出此错误的两个原因.我只是想帮助人们不用花上一小时又一小时的时间.
查看答案&;以下情况:)
情况1: try 打印数组中的值.
Answer 1: Try printing out the array. Are you sure it's an array? I've gotten this error when it was an object instead of an array. Try doing a print_r and seeing what you get.
情景2:
Array
(
[post_id] => 65
[post_text] => Multiple Images!
[created_at] => 2014-10-23 09:16:46
[updated_on] =>
[post_category] => stdClass Object
(
[category_label] => Help Wanted
[category_code] => help_wanted
)
[employee_full_name] => Sam Jones
[employee_pic] => /images/employee-image-placeholder.png
[employee_email] => jon@gmail.com
[post_images] => Array
(
[0] => stdClass Object
(
[image_path] => 9452photo_2.JPG
)
[1] => stdClass Object
(
[image_path] => 8031photo_3.JPG
)
)
)
当您试图直接在视图中访问post_images数组时,它会抛出一个错误.No. Matter. What. You. Do.
答复2:
I hope this helps someone else. :) I just know the error I kept getting didn't help me anywhere.