Home > php教程 > php手册 > body text

一个PHP日历程序

WBOY
Release: 2016-06-13 12:35:30
Original
800 people have browsed it

// 
if($HTTP_GET_VARS[year]=="") 

    $HTTP_GET_VARS[year]=date("Y"); 

if($HTTP_GET_VARS[month]=="") 

    $HTTP_GET_VARS[month]=date("n"); 

$month=$HTTP_GET_VARS[month]; 
$year=$HTTP_GET_VARS[year]; 
// 
if($year{ 
    echo "出错!"; 
    echo "
"; 
    echo "Back"; 
    exit(); 

?> 

 
 
  
$d=date("d"); 
$FirstDay=date("w",mktime(0,0,0,$month,1,$year));//取得任何一个月的一号是星期几,用于计算一号是由表格的第几格开始 
$bgtoday=date("d"); 
function font_color($month,$today,$year)//用于计算星期天的字体颜色 

    $sunday=date("w",mktime(0,0,0,$month,$today,$year)); 
    if($sunday=="0") 
    { 
        $FontColor="red"; 
    } 
    else 
    { 
        $FontColor="black"; 
    } 
    return $FontColor; 

function bgcolor($month,$bgtoday,$today_i,$year)//用于计算当日的背景颜色 

    $show_today=date("d",mktime(0,0,0,$month,$today_i,$year)); 
    $sys_today=date("d",mktime(0,0,0,$month,$bgtoday,$year)); 
    if($show_today==$sys_today) 
    { 
        $bgcolor="bgcolor=#6699FF"; 
    } 
    else 
    { 
        $bgcolor=""; 
    } 
    return $bgcolor; 

function font_style($month,$today,$year)//用于计算星期天的字体风格 

    $sunday=date("w",mktime(0,0,0,$month,$today,$year)); 
    if($sunday=="0") 
    { 
        $FontStyle=""; 
    } 
    else 
    { 
        $Font; 
    } 
    return $FontStyle; 

for($i=0;$i{ 
    for($i;$i    { 
        echo "
\n"; 
    } 
    if($i==$FirstDay) 
    { 
        echo "
\n"; 
        if($FirstDay==6)//判断1号是否星期六 
        { 
            echo "
"; 
        } 
    } 

$countMonth=date("t",mktime(0,0,0,$month,1,$year));//某月的总天数 
for($i=2;$i{ 
    echo "\n"; 
    if(date("w",mktime(0,0,0,$month,$i,$year))==6)//判断该日是否星期六 
    { 
    echo "\n"; 
    } 

?> 
 
// 
if($month{ 
    $month=12; 
    $year-=1; 

if($month>12) 

    $month=1; 
    $year+=1; 

// 
//*************************************** 
// 
echo ">>"; 
?> 
 
 
echo ">>"; 
// 
   ?>
 ".font_style($month,1,$year)."1
".font_style($month,$i,$year)."$i


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template