CodeIgniter:致命错误:不能在写上下文中使用方法返回值


CodeIgniter: Fatal error: Can't use method return value in write context

我有这个问题,我张贴响应到控制器,但它抛出这个错误。这是我第一次遇到这个错误。

请查看下面的代码:

    if (isset($this->input->post('responseCode'))) 
       {
         echo '<p><strong>Cardstream Response</strong></p>';
         echo '<pre>';
         print_r($this->input->post());
         echo '</pre>';
       }

指向if (isset($this->input->post('responseCode')))

这是一个卡流集成。不幸的是,我在codeigniter中没有找到cardstream的库,因此我使用了相同的核心PHP代码。

任何帮助都将非常感激。谢谢。

您正在对方法使用isset(),该方法可能返回表达式结果。您不能这样做,因为isset()仅用于变量。试着检查它是否为空:

if ($this->input->post('responseCode') !== null) {...

或简单的:

if ($this->input->post('responseCode')) {...

使用

if ($this->input->post('responseCode'))

代替isset()检查

你不能在一个函数上使用isset

if($this->input->post('responsecode'))

if(!empty($this->input->post('responsecode')))