致命错误:第20行上不支持的操作数类型

时间:2011-03-14 05:29:39

标签: php pyrocms

第20行:$ this-> data ['available_credits'] = $ total_credits - $ used_credits;

    function index()   {
    $user_id = $this->session->userdata('user_id');
    $this->data['credits'] = $this->credit_m->get_credit_details($user_id);
    $total_credits = $this->data['total_credits'] = $this->credit_m->get_total_credits($user_id);
    $used_credits = $this->data['used_credits'] = $this->credit_m->get_used_credits($user_id);
    $this->data['available_credits'] = $total_credits - $used_credits;
    $this->template->build('credits_view',$this->data);
}

1 个答案:

答案 0 :(得分:1)

我猜你的$total_credits变量$used_credits不包含数字 - 它们可能包含一些无法减去的对象。

检查您的get_total_credits()get_used_credits()方法返回的内容;确保它们返回可与减法运算符一起使用的值。