0

何らかの理由で PHP コードが機能しません。 でエラーが発生しelseifます。使ったことがないのでよくわかりませんelseifが、YouTubeで使用できるのを見たことがありますが、これを理解するために本当に助けが必要ですが、設定する前にうまくいきまし$status1-2 = closedmsg1-2た 答えまたは別の方法を知っています$status1-2 = closedmsg1-2か? 「String Replacer」または「String Set」も少し検索しましたが、見つかりません。

<?php
//Made by Arnem\\

//\\Options//\\
$closed = 2000;
$opend = 1500;
$openmsg = '<p class=customfont>Streaming status: Online</p>';
$closemsg = '<h1 class=customfont2>Streaming is currently offline!</h1>';
$closemsg2 = '<p class=customfont>Streaming status: Offline</p>';
//DO NOT CONFIGURE UNDER THIS LINE!\\
$time = gmdate(H)+1 . gmdate(i);
if ($time>$closed)
$status1 = $closemsg;
$status2 = $closemsg2;
elseif ($time<$opend)
$status1 = $closemsg;
$status2 = $closemsg2;
else
$status2 = $openmsg;

echo$status1;
echo $status2;
?>
4

2 に答える 2

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 の場合だけです。

于 2013-01-18T22:33:23.400 に答える
1

中かっこが必要です (中かっこなしで実行できるのは、単一のステートメント ブランチのみです)。

if ($time>$closed) {
    $status1 = $closemsg;
    $status2 = $closemsg2;
} elseif ($time<$opend) {
    $status1 = $closemsg;
    $status2 = $closemsg2;
} else {
    $status2 = $openmsg;
}
于 2013-01-18T22:33:27.783 に答える