我无法在PHP中获得返回值[关闭]

I can't get the return value! The Output appears 'ERROR'.

$c = new List();
$result = $c->create();

if( $result == "a"){
   echo("A");                   
}else if($result == "b"){
   echo("B");
}else{
   echo("ERROR");
}

class List{

    function create(){

       // $rVal = ...

       if($rVal == 1){
           return "a";
       }else if($rVal == 2){
           return "b";
       }
    }
}

when I change return to echo, the output appears 'aERROR'. I don't understand. create function works but the return value is not true. Can anyone help me please? Sorry for my bad English

If the code below is correct, then you are not setting $rVal. The assignment seems commented out:

class List{

    function create(){

       // $rVal = ...

       if($rVal == 1){
           return "a";
       }else if($rVal == 2){
           return "b";
       }
    }
}

So, nothing (null) will be returned by create() call... which is interpreted as false.