SpeedPHP支持模版使用switch么?

#1 zf19870131

SpeedPHP支持模版使用switch么?

如题。如果使用if判断的话,太麻烦。

2010-04-24 19:29:15

#2 jake

speedphp的smarty模板应该是不支持switch的,建议用if elseif else 等。

其实PHP目前的语法来说,switch已经是不建议使用的语法了。

另外,在speedphp 3中,speedy模板是可以用switch的。

2010-04-24 20:32:21

#3 hiramli

那可以試一下 SPEEDY 中使用 SWITCH 的例子嗎 ?

謝 !!

2010-04-25 02:15:51

#4 superphp

我也想看看,不过没用过switch。

2010-04-25 10:07:31

#5 jake

template.html

switch ($i) {
    case 0:
print <<这里是HTML内容
EOT;
    break;
    case 1:
        print <<这里是HTML内容
EOT;
break;
    case 2:
        print <<这里是HTML内容
EOT;
break;
}?>
或者
switch ($i):
    case 0:
        print <<这里是HTML内容
EOT;        break;
    case 1:
        print <<这里是HTML内容
EOT;
break;
    case 2:
        print <<这里是HTML内容
EOT;
break;
    default:
        print <<这里是HTML内容
EOT;
endswitch;
?>

2010-04-25 10:24:46