0
votes

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

1 Answers

4
votes

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']))?