在我筛选数据的时候,有几个页面可以出来有几个就报这样的错误!!!!
我的问题是因为其中有些数据是不存在的,所以就报错了
现在就是过滤掉为空的情况就可以了
//例子1
<td class="text-center">
{if !empty($list['channel'])}
{$list['channel']->name}
{/if}
</td>
// 例子2 $sum['weight'] = empty($sum['weight'])? 0: round($sum['weight'], 2);
//例子3
if (!empty($sum['customer']['username'])) {
$all_list[$sum['customer']['username']][] = $sum;
}
if(!isset($result[$sum['customer']['username']])) {
$result[$sum['customer']['username']]['count'] = 0;
$result[$sum['customer']['username']]['weight'] = 0;
$result[$sum['customer']['username']]['amount'] = 0;
$result[$sum['customer']['username']]['supplier_fee'] = 0;
}
总计一下吧!!
这个错误通常发生在:
1.尝试访问一个非对象的属性时
2.数据属性为空(我的就是对象里面的某些个属性为空)
要解决这个问题:
1)首先要确保$list['channel']是一个对象,而不是其他类型的数据。
你可以使用var_dump($list['channel'])来检查变量的类型。
2)如果$list['channel']确实是一个对象,那么可能是该对象中没有name属性。
你可以使用var_dump($list['channel'])或者print_r($list['channel'])来查看对象的结构,并确保它包含了name属性。(可以过滤掉为空情况的数据)