dongweihuan8832 2013-03-17 21:57
浏览 45
已采纳

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

I am trying to make a small survey form asking people questions and replying either yes or no.

I am trying though to execute the the first two functions on the 3rd function and also check if the answers were set but i get a:

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

Can someone please help me or point me to the right path?

    <?php
class survey {

    ... some functions ...

    function check($rep1, $rep2){

        if (isset($this->q1($rep1)) && isset($this->q2($rep2))) {
            #######################    #######################
            echo "Thank you for the feedback";
        }elseif (! array_key_exists(@$_POST['answer'], $var)) {
            echo "Please select an option<br/>";
        }
    }
}
?>

The error is inside the check function on the first line.

  • 写回答

1条回答 默认 最新

  • dongzhi1822 2013-03-17 22:01
    关注

    Since functions always return something (even if it's NULL), using isset() on them is nonsensical.

    isset is a language construct that takes a variable name and tells you if it exists.

    In this case, why not just write if(isset($_POST['answer']))?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)