猿问

关于php的switch语句的问题!

switch ($RX_TYPE)
{
case "text":
$result = $this->receiveText($postObj);
break;

case "voice":
$result = $this->receiveText1($postObj);
break;

case "event":
$resultStr = $this->receiveEvent($postObj);
break;
default:
$result = "unknown msg type: ".$RX_TYPE;
break;
}

比如这个 如果 我接收到的$RX_TYPE是voice 那就想运行两个方法
receiveText1()和receiveText2()
就是 关键词voice的时候 先运行receiveText1() 再运行 receiveText2()


偶然的你
浏览 393回答 2
2回答

函数式编程

123456789101112131415161718switch ($RX_TYPE)            {                case "text":                    $result = $this->receiveText($postObj);                    break;                      case "voice":                    $result1 = $this->receiveText1($postObj);                    $result2 = $this->receiveText2($postObj);//你为什么不给他加上一个调用的方法 运行完1运行2 这样不可以吗 我不懂。。。                    break;          case "event":                    $resultStr = $this->receiveEvent($postObj);                    break;                default:                    $result = "unknown msg type: ".$RX_TYPE;                    break;            } 

小唯快跑啊

case "voice":receiveText1();receiveText2();break;直接写好了
随时随地看视频慕课网APP
我要回答