Alternative syntax for switch

前端 未结 1 1831
一个人的身影
一个人的身影 2021-01-11 21:40

Hey there is an alternative syntax for switch statement in PHP, but this code doesn\'t work:

相关标签:
1条回答
  • 2021-01-11 22:07

    Solution for this problem is putting switch($variable): with case 1: into same block of PHP code:

    <div>
    <?php switch($variable): 
    case 1: ?>
    <div>
    Newspage
    </div>
    <?php break;?>
    <?php case 2: ?>
    </div>
    Forum
    <div>
    <?php break;?>
    <?php endswitch;?>
    </div>
    
    0 讨论(0)
提交回复
热议问题