Tutorial :php error: Fatal error: Can't use function return value in write context in /home/fadnyc/public_html/newstudent.php on line 62



Question:

for ($i=0; $i<10; $i++) {      if ($choices($i)) {           if ($selection(0)=='first'){                   $selection(0)= $choices($i);  // line 62           }          else{ $selection(1) = $choices($i);         }           echo "ctr " . $ctr . $choices($i) ."<br />";      }          }    


Solution:1

In PHP, use square brackets for array indices.

for ($i=0; $i<10; $i++) {      if ($choices[$i]) {            if ($selection[0]=='first') {                $selection[0] = $choices[$i]; // line 62           } else{                $selection[1] = $choices[$i];           }           echo "ctr " . $ctr . $choices[$i] ."";      }  }   


Solution:2

What is $selection? Unless it contains the name of a function, you are doing something wrong. Same with $choices.

Perhaps you are confusing array notation [] with function notation ()?


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »