第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);
}
答案 0 :(得分:1)
我猜你的$total_credits
变量$used_credits
不包含数字 - 它们可能包含一些无法减去的对象。
检查您的get_total_credits()
和get_used_credits()
方法返回的内容;确保它们返回可与减法运算符一起使用的值。