donglaoe2979
2016-10-28 05:11
浏览 43
已采纳

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

I have this issue where I am posting a response into the controller, however it throws this error. This is the first time I am coming across this error.

Kindly find the code below:

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

It is pointing at this particular line if (isset($this->input->post('responseCode')))

This is a cardstream integration. Unfortunately I haven't found the library for cardstream in codeigniter, hence I am using the Core PHP code for the same.

Any help will be greatly appreciated. Thanks.

图片转代码服务由CSDN问答提供 功能建议

我有这个问题,我将响应发布到控制器,但它会抛出此错误。 这是我第一次遇到这个错误。

请找到下面的代码:

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

它指向此特定行 if(isset($ this-&gt; input-&gt; post('responseCode')))

这是一个 cardstream集成。 不幸的是我没有在codeigniter中找到cardstream的库,因此我使用的是同样的Core PHP代码。

任何帮助将不胜感激。 谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongxu8533486 2016-10-28 05:16
    已采纳

    You are using isset() on a method, which presumably returns a expression result. You cannot do that because isset() is only used on variables. Try checking if it's null instead:

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

    Or simply:

    if ($this->input->post('responseCode')) {...
    
    点赞 打赏 评论
  • dongpan5289 2016-10-28 05:15

    Use this

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

    instead isset() checking

    点赞 打赏 评论
  • duanguangwang5829 2016-10-28 05:17

    you cant use isset on a function you couldusse

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

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

    点赞 打赏 评论

相关推荐 更多相似问题