Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当我在codeigniter中使用count函数时,它会给我带来错误_Php_Codeigniter - Fatal编程技术网

Php 当我在codeigniter中使用count函数时,它会给我带来错误

Php 当我在codeigniter中使用count函数时,它会给我带来错误,php,codeigniter,Php,Codeigniter,如何在CodeIgniter中使用计数功能,我最近正在将xampp7.2更新为7.2.12 这是我的代码,我正在这样尝试 print_r(count($this->input->post('disp_ch_ids'))); exit(); 它给了我这个错误: 遇到一个PHP错误 严重性:警告 Message:count():参数必须是数组或实现可计数的对象 文件名:dispatch_challan/dispatch challancontroller.php 电话号码:24

如何在CodeIgniter中使用计数功能,我最近正在将xampp
7.2
更新为
7.2.12

这是我的代码,我正在这样尝试

 print_r(count($this->input->post('disp_ch_ids')));
   exit();
它给了我这个错误:

遇到一个PHP错误 严重性:警告 Message:count():参数必须是数组或实现可计数的对象 文件名:dispatch_challan/dispatch challancontroller.php 电话号码:24


不知道“disp_ch_id”是否真的是“可数的”(在本文中指的是一个
数组
),但假设它是,我们首先需要确定它是否有任何值

input::post()
如果
$\u post['disp\u chu id']
不存在,则将返回
NULL
。但它可以是空字符串,也可以是没有项的数组

$ch_ids = $this->input->post('disp_ch_ids');

// does $ch_ids contain anything?
if( ! empty($ch_ids))
{
    //but is it "countable"
    if(is_array($ch_ids))
    {
        //OK to count it
        print_r(count($ch_ids));
    }
    else
    {
        print_r($ch_ids);
    }
}

disp_ch_id是一个提交形式的数组。由于错误是明确的,所以可以对数组或对象使用count。您想做什么?根据PHP7.2中的-。他们添加了一个警告,如果你没有传递一个实现
Countable
sizeOf()的数组或对象,那么它会给我同样的错误@sougatabosei,如果你想计算你的输入,那么就这样做$所有_值=$this->input->post();然后计数($all_值);