我的目标是根据星期几和用户来自的链接换出背景图像。
例子:
星期一,index.php = bg1.jpg
星期一,about.php = bg2.jpg
星期二,index.php = bg3.jpg
星期二,about.php = bg4.jpg
这是我处理本周情况的开关,但不知道如何从这里开始:
<?php
// Variables
$url = "images/days/";
$monImage = "$url"."bg_mon_a.jpg";
$tueImage = "$url"."bg_tue_a.jpg";
$wedImage = "$url"."bg_wed_a.jpg";
$thurImage = "$url"."bg_thu_a.jpg";
$friImage = "$url"."bg_fri_a.jpg";
$weekendImage = "$url"."bg_default.jpg";
$d = date("D");
//Function that switches between date images based on the actual day of the week in $d
switch ($d)
{
case Mon:
echo "<img id='bg_image' src=$monImage>\n";
break;
case Tue:
echo "<img id='bg_image' src=$tueImage>\n";
break;
case Wed:
echo "<img id='bg_image' src=$wedImage>\n";
break;
case Thu:
echo "<img id='bg_image' src=$thurImage>\n";
break;
case Fri:
echo "<img id='bg_image' src=$friImage>\n";
break;
default:
echo "<img id='bg_image' src=$weekendImage>\n";
}
//End
?>