這篇文章主要介紹“怎么用php制作日歷”,在日常操作中,相信很多人在怎么用php制作日歷問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用php制作日歷”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
calendar.class.php
復(fù)制代碼 代碼如下:
class Calendar {
private $year; //當(dāng)前的年
private $month; //當(dāng)前的月
private $start_weekday; //當(dāng)月的第一天對應(yīng)的是周幾
private $days; //當(dāng)前月一共多少天
function __construct(){
$this->year=isset($_GET["year"]) ? $_GET["year"] : date("Y");
$this->month=isset($_GET["month"]) ? $_GET["month"] : date("m");
$this->start_weekday=date("w", mktime(0, 0, 0, $this->month, 1, $this->year));
$this->days=date("t", mktime(0, 0, 0, $this->month, 1, $this->year));
}
function out(){
echo '
private function weeksList(){
$week=array('日','一','二','三','四','五','六');
echo '
echo '
private function daysList(){
echo '
for($k=1; $k<=$this->days; $k++){
$j++;
if($k==date('d'))
echo '
if($j%7==0)
echo '
//后面幾個空格
while($j%7!==0){
echo '
echo '
private function prevYear($year, $month){
$year=$year-1;
if($year < 1970)
$year = 1970;
return "year={$year}&month={$month}";
}
private function prevMonth($year, $month){
if($month == 1) {
$year = $year -1;
if($year < 1970)
$year = 1970;
$month=12;
}else{
$month--;
}
return "year={$year}&month={$month}";
}
private function nextYear($year, $month){
$year = $year + 1;
if($year > 2038)
$year = 2038;
return "year={$year}&month={$month}";
}
private function nextMonth($year, $month){
if($month==12){
$year++;
if($year > 2100)
$year=2100;
$month=1;
}else{
$month++;
}
return "year={$year}&month={$month}";
}
private function chageDate($url=""){
echo '
echo '
}
?>
test.php
復(fù)制代碼 代碼如下:
include "calendar.class.php";
$calendar=new Calendar;
$calendar->out();
?>
到此,關(guān)于“怎么用php制作日歷”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!