试图获取非对象错误的属性请帮助

时间:2016-01-21 04:02:14

标签: php

<div class="manga-created pull-right">
    <i class="fa fa-user"></i>
    <small><?php echo $manga->user->username; ?>,</small>
    <i class="fa fa-calendar-o"></i>
    <small><?php echo App::make("HelperController")->formateCreationDate($manga->created_at); ?></small>
</div>

这一行是我收到错误的地方:

<small><?php echo $manga->user->username; ?>,</small>

1 个答案:

答案 0 :(得分:1)

看起来$manga$manga->user中的一个不是对象。所以它应该就像其中之一:

<?php echo $manga->user['username']; ?>

<?php echo $manga['user']->username; ?>