首页 > php switch 语句中不能做判断吗

php switch 语句中不能做判断吗

switch($data['MsgType']){
                case "text" :
                $this->Text($wechat,$data);
                
                case "event":
                if(!$data['EventKey']){
                    $text="没有EVENTKEY";
                    $this->logger("发送消息:\n".$text);
                    $this->Text($wechat,$data);
                }
                
                $this->eventKey($wechat,$data);
            }

这样写了但是判断不出来


每个case结束时要加 break;

switch($data['MsgType']){
    case "text" :
        $this->Text($wechat,$data);
        break;
    case "event":
        if(!$data['EventKey']){
            $text="没有EVENTKEY";
            $this->logger("发送消息:\n".$text);
            $this->Text($wechat,$data);
        }

        $this->eventKey($wechat,$data);
        break;
}
【热门文章】
【热门文章】