亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP開發(fā)之製作簡單日曆引用CLASS類

1、new一個Calendar類別

2、初始化兩個下拉框中的數(shù)據(jù),年份與月份

3、初始化要搜尋的年份和月份

4.計算得出日曆中每一天的資料訊息,包括css、天數(shù)

引用前面封裝的Calendar類別

<?php
include_once 'calendar.php';
?>

?The?include_once()?語句在腳本執(zhí)行期間包含並運行指定檔案。此行為和?include()?語句類似,唯一差異是如果該檔案中的程式碼已經(jīng)被包含了,則不會再次包含。如同此語句名字暗示的那樣,只會包含一次。

實例化這個類別:

<?php
$util = new Calendar();
?>

還需要定義年份和月份陣列用POST方式取得

<?php
$years = array(2014, 2015, 2016, 2017, 2018);//年份選擇自定義
$months = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);//月份數(shù)組
//獲取post的年份數(shù)據(jù)
if(empty($_POST['ddlYear'])) {
   $year = date('Y');
}else {
   $year = $_POST['ddlYear'];
}
//獲取post的月份數(shù)據(jù)
if(empty($_POST['ddlMonth'])) {
   $month = date('n');
}else {
   $month = $_POST['ddlMonth'];
}
?>

透過實例化類別取得threshold方法,caculate方法和draw方法。

<?php
$calendar = $util->threshold($year, $month);//獲取各個邊界值
$caculate = $util->caculate($calendar);//獲取計算日歷的天數(shù)與樣式
$draws = $util->draw($caculate);//畫表格,設(shè)置table中的tr與td
?>


#
繼續(xù)學習
||
<?php include_once 'calendar.php'; $util = new Calendar(); //實例化一個類 $years = array(2014, 2015, 2016, 2017, 2018);//年份選擇自定義 $months = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);//月份數(shù)組 //獲取post的年份數(shù)據(jù) if(empty($_POST['ddlYear'])) { $year = date('Y'); }else { $year = $_POST['ddlYear']; } //獲取post的月份數(shù)據(jù) if(empty($_POST['ddlMonth'])) { $month = date('n'); }else { $month = $_POST['ddlMonth']; } $calendar = $util->threshold($year, $month);//獲取各個邊界值 $caculate = $util->caculate($calendar);//獲取計算日歷的天數(shù)與樣式 $draws = $util->draw($caculate);//畫表格,設(shè)置table中的tr與td ?>