我的目標是根據星期幾和用戶來自的鏈接換出背景圖片。基於日期和網址的PHP圖像交換
例如:
星期一的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
?>
你遇到問題的部分究竟是什麼?爲交換機添加額外的標準,或獲取引用鏈接的名稱?如果沒有引用鏈接,你會做什麼? – andrewsi 2012-07-13 18:14:18