我们正在尝试为变量创建 if/elseif 语句$day
。我们在与此 PHP 关联的 HTML 代码中定义了变量及其值。我会将 PHP 部分粘贴到此页面。问题是结果页面只给出“$day = 1”的响应。有谁知道此代码中的错误会导致这种情况发生?我们还尝试使用两个等号,但这让情况变得更糟!
echo "<p>";
if ($day = 1) {
echo "Sunday Funday! What COMMITMENT to going out!";
} elseif ($day = 2) {
echo "The start of what's sure to be a rough week. Drink away your sorrows.";
} elseif ($day = 3) {
echo "Epic night! SO many themes at the bars!";
} elseif ($day = 4) {
echo "Hump day!! But seriously, what are you doing...? Aren't you too hungover from last night?";
} elseif ($day = 5) {
echo "Thirsty Thursday!! It's close enough to the weekend... right?";
} elseif ($day = 6) {
echo "It's Friiiiiiday, Friiiiiiiday, Gotta get down on Friiiiiiiiiday!";
} elseif ($day = 7) {
echo "It's FRATurday! Go have some fun!";
}