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 關注
- 96 瀏覽
添加回答
舉報