熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

簡單的PHP日歷算法

2013-11-15 12:25:55  來源: PHP編程 
/** 
  * 日歷 
  * 
  * Copyright(c) by 陳毅鑫(深空) All rights reserved 
  * To contact the author write to
{@link mailto:shenkong@phpnet
  * @author 陳毅鑫(深空) 
  */
 if (function_exists(date_default_timezone_set)) { 
     date_default_timezone_set(Asia/Chongqing); 
 } 
 $date = isset($_GET[date]) ? $_GET[date] : date(Ymd); 
 $date = getdate(strtotime($date)); 
 $end = getdate(mktime( $date[mon] + $date[year]) );
 $start = getdate(mktime( $date[mon] $date[year])); 
 $pre = date(Ymd $start[] ); 
 $next = date(Ymd $end[] + ); 
 $html = <table border="">
 $html = <tr>
 $html = <td><a href=" $PHP_SELF ?date= $pre "></a></td>
 $html = <td colspan=""> $date[year] ; $date[month] </td>
 $html = <td><a href=" $PHP_SELF ?date= $next ">+</a></td>
 $html = </tr>
 $arr_tpl = array( => => => => => => => );
 $date_arr = array(); 
 $j =
 for ($i = ; $i < $end[mday]; $i++) { 
     if (!isset($date_arr[$j])) { 
         $date_arr[$j] = $arr_tpl; 
     } 
     $date_arr[$j][($i+$start[wday])%] = $i+
     if ($date_arr[$j][]) { 
         $j++; 
     } 
 } 
 foreach ($date_arr as $value) { 
     $html = <tr>
     foreach ($value as $v) { 
         if ($v) { 
             if ($v == $date[mday]) { 
                 $html = <td><b> $v </b></td>
             } else { 
                 $html = <td> $v </td>
             } 
         } else { 
             $html = <td>&nbsp;</td>
         } 
     } 
     $html = </tr>
 } 
 $html = </table>
 echo $html;  

 
From:http://tw.wingwit.com/Article/program/PHP/201311/20942.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.