我昨天發佈了代碼中的很多錯誤,所以我去了並重新開始。代碼沒有顯示任何東西是否有一些即時消息missing.Im新到這麼試當我加載到我的本地主機時,它返回的是'無效季節'PHP代碼。顯示季節(第2輪)
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$season = array('winter','spring','summer','autumn');
function getWinterMonths(){
$WinterMonths = array(
1 => array('November'),
2 => array('December'),
3 => array('January')
);
return $WinterMonths;
}
function getSpringMonths(){
$SpringMonths = array(
1 => array('February'),
2 => array('March'),
3 => array('April')
);
return $SpringMonths;
}
function getSummerMonths(){
$SummerMonths = array(
1 => array('May'),
2 => array('June'),
3 => array('July')
);
return $SummerMonths;
}
function getAutumnMonths(){
$AutumnMonths = array(
1 => array('August'),
2 => array('September'),
3 => array('October')
);
return $AutumnMonths;
}
if($season == "winter")
echo $WinterMonths();
else if($season == "spring")
echo $SpringMonths();
else if($season == "summer")
echo $SummerMonths();
else if($season == "autumn")
echo $AutumnMonths();
else{
echo "Invalid season entred";
}
你不叫「getSeasonMonths」,但你所說的變量,它被聲明爲函數($ seasonMonths)...範圍的問題,對不對?順便說一句,$季節是一個數組,它不能是==「夏天」!但$季節[1]或[0]可以... – Julo0sS
你能說出你正在試圖存檔嗎? – Kordi