codeigniter 合并两种输入发布方法

qni6mghb  于 2023-09-28  发布在  其他
关注(0)|答案(2)|浏览(72)

我有一个简单的问题,有关输入法后.有如下两个输入字段:

$this->input->post('billed_date')
$this->input->post('branch_id')

然后,我想使用逻辑“或”参数合并这两个输入post方法。我使用了以下代码:

if($this->input->post('billed_date', 'branch_id'))
{       
        .....some codes...
}

但没有得到预期的结果。如何使用“OR”将这两个post方法结合起来?有人能帮忙吗?

crcmnpdw

crcmnpdw1#

CodeIgniter的输入库的post()方法不支持以这种方式传递多个键。你需要像这样单独做:

if ($this->input->post('billed_date') && $this->input->post('branch_id'))
{
    // ...your code here...
}

如果你需要它作为逻辑OR(例如,只需要存在一个变量),你可以这样做:

if ($this->input->post('billed_date') || $this->input->post('branch_id'))
{
    // ...your code here...
}
ctrmrzij

ctrmrzij2#

为了更好地理解在if条件中使用isset函数

if (isset($this->input->post('billed_date')) || isset($this->input->post('branch_id')))
{
    // ...your code here...
}

或者你可以使用OR替换||然后像下面这样编码

if (isset($this->input->post('billed_date')) OR isset($this->input->post('branch_id')))
{
    // ...your code here...
}

相关问题