1 回答
TA贡献1799条经验 获得超9个赞
首先通过这样做清理你的烂摊子。而不是使用 if-elseif-else。使用开关盒方法。
<?php
if(isset($_POST['testType'])){
$testType = $_POST['testType'];
switch($testType){
case 'japTofr':
case 'frTojap': ?>
//put your HTML FORM here
<?php
break;
case 'conjugation': ?>
//put your conjugation html here
<?php
break;
default: ?>
//put your HTML here for testType == group (your else condition)
<?php
}
}else{ ?>
//put yout HTML here if no testType has been set
<?php
}
?>
或者另一种方式是这样
<?php
if(isset($_POST['testType'])):
$testType = $_POST['testType'];
switch($testType):
case 'japTofr':
case 'frTojap': ?>
//put your HTML FORM here
<?php
break;
case 'conjugation': ?>
//put your conjugation html here
<?php
break;
default: ?>
//put your HTML here for testType == group (your else condition)
<?php
endswitch;
else: ?>
//put yout HTML here if no testType has been set
<?php
endif;
?>
- 1 回答
- 0 关注
- 73 浏览
添加回答
举报