PHP練手:日曆(代碼簡單,擴充容易)_PHP教程

來源:互聯網
上載者:User

PHP練手:日曆(代碼簡單,擴充容易)


抽空寫了個行事曆程式,只注重功能和實現的思路,所以代碼和功能都比較簡單,但是理解和擴充也比較容易。

show()函數用來顯示日曆,你可以修改show()函數,通過傳值的方式來實現顯示不同的年月。

';            echo ''.$year.'-'.$month.'';            echo '星期日星期一星期二星期三星期四星期五星期六';            //取得當前月有多少天            $yearMonth = '$year."-".$month';            $monthNum = $this->getMonthNum($yearMonth);            //取得當前月第一天是星期幾            $this->firstDay = $year."-".$month."-01";            $this->firstNum = $this->getWeek($this->firstDay);            $this->firstDayNum = $this->weekarray[$this->firstNum];                        echo '';                for($i=1;$i<=$monthNum+($this->firstNum);$i++){                    echo '';                    if($i >= $this->firstNum+1){                        $a = $i-$this->firstNum;                        if($a == $day){                            echo ''.$a.'';                        }else{                            echo ''.$a.'';                        }                    }                    echo '';                    if($i%7 == 0){//每輸出7列就換一行                        echo '';                    }                }            echo '';        }    }        $calendar = new Calendar();    $calendar->show();


PHP date()函數的使用

這裡有篇date()函數的詳解:http://wenku.baidu.com/link?url=OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_7H4XBILv8JfomhbnSxXSW0FhqxYBK0_gn8Nr77XMWp-_st7v8AYecbNZjG

http://www.bkjia.com/PHPjc/847853.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/847853.htmlTechArticlePHP練手:日曆(代碼簡單,擴充容易) 抽空寫了個行事曆程式,只注重功能和實現的思路,所以代碼和功能都比較簡單,但是理解和擴充也比...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.