牛骨文教育服务平台(让学习变的简单)
博文笔记

html嵌套php:switch

创建时间:2015-07-31 投稿人: 浏览次数:777
转载:http://www.cnblogs.com/glory-jzx/p/3345685.html
If you wan"t to use the alternative syntax for switch statements this won"t work:

<div>
<?php switch($variable): ?>
<?php case 1: ?>
<div>
Newspage
</div>
<?php break;?>
<?php case 2: ?>
</div>
Forum
<div>
<?php break;?>
<?php endswitch;?>
</div>

Instead you have to workaround like this:

<div>
<?php switch($variable): 
case 1: ?>
<div>
Newspage
</div>
<?php break;?>
<?php case 2: ?>
</div>
Forum
<div>
<?php break;?>
<?php endswitch;?>
</div>


看了半天原来是PHP 的BUG。。。 唉。。。

 switch : 和 case 之间是不能有任何输出的。。。  PS : 一个空格也不行。。 

you may see the comment in this link ........http://php.net/manual/en/control-structures.alternative-syntax.php

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。