話不多說看程式碼
正常寫法
<?
$Sunday="星期日";
$Monday="星期一";
$Tuesday="星期二";
$Wednesday="星期三";
$Thursday="星期四";
$Friday="星期五";
$Saturday="星期六";
$today=date("l"); //l==L date("l") php函數 取得星期幾]
if($today=="Sunday"){
echo "<br>今天是{$Sunday}";
}elseif($today=="Monday"){
echo "<br>今天是{$Monday}";
}
elseif($today=="Tuesday"){
echo "<br>今天是{$Tuesday}";
}
elseif($today=="Wednesday"){
echo "<br>今天是{$Wednesday}";
}
elseif($today=="Thursday"){
echo "<br>今天是{$Thursday}";
}
elseif($today=="Friday"){
echo "<br>今天是{$Friday}";
}
elseif($today=="Saturday"){
echo "<br>今天是{$Saturday}";
}
echo "<br>";
echo "<br>";
echo "使用$$";
echo "<br>今天是{$$today}";
?>
使用$$可以少寫很多的if
但結果都一樣
沒有留言:
張貼留言