由于某种原因,我的PHP代码无效,我在elseif
上收到错误。我无法弄明白,因为我从未使用elseif
,但我在YouTube上看到你可以使用它,但我真的想要一些帮助来解决这个问题,但在我设置之前它工作正常{ {1}}。
您是否知道答案或其他方式$status1-2 = closedmsg1-2
?
我也搜索了一下“String Replacer”或“String Set”,但我找不到它。
$status1-2 = closedmsg1-2
答案 0 :(得分:2)
尝试
if ($time>$closed){
$status1 = $closemsg;
$status2 = $closemsg2;
}elseif ($time<$opend){
$status1 = $closemsg;
$status2 = $closemsg2;
}else{
// are you missing $status1 here? could be why its not working
$status2 = $openmsg;
}
您错过了大括号{}
。如果没有它们,唯一的时间就是它的单个陈述if / else。
答案 1 :(得分:1)
你需要大括号(只有一个语句分支可以不用它们)。
if ($time>$closed) {
$status1 = $closemsg;
$status2 = $closemsg2;
} elseif ($time<$opend) {
$status1 = $closemsg;
$status2 = $closemsg2;
} else {
$status2 = $openmsg;
}