1、php if...else 在html中的替代语法
<?php $name = ‘ok‘ ?> <?php if ($name == ‘1ok‘) : ?> <div>this is first</div> <?php else: ?> <div>this is second</div> <?php endif ?>
2、php for在html中的替代语法
<?php for ($i = 0; $i < 10; $i++): ?> <div>are you ok???</div> <?php endfor ?>
3、php switch在html中的替代语法
<?php $a = 6 ?> <?php switch (true): ?> <?php case $a == 3: ?> <div>this is first</div> <?php break; ?> <?php case $a == 4: ?> <div>this is second</div> <?php break; ?> <?php case $a == 5: ?> <div>this is third</div> <?php break; ?> <?php default: ?> <div>没有可匹配的了</div> <?php endswitch ?>
原文:https://www.cnblogs.com/rickyctbu/p/10493401.html