PHP 간단 한 달력 구현 방법
실행 효과 캡 처 는 다음 과 같 습 니 다:
구체 적 인 코드 는 다음 과 같다.
<?php
/*
* Created on 2016-7-20
*/
SimCalendar('2016-08');// 8
function SimCalendar($date)
{
/**
* , cal_days_in_month
* @param $date Y-m
*/
echo '<table border="1">
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>';
$date_array = explode('-', $date);
$start_week = 0;// 0
$month = cal_days_in_month(CAL_GREGORIAN, $date_array[1], $date_array[0]);//
$wstar = date('w', strtotime($date . '-01'));//
$rows = ceil(($wstar + $month) / 7);//
$mday = 1;//
for ($i = 0; $i < $rows; $i++) {
echo '<tr>';
for ($d = 0; $d < 7; $d++) {
$nowday = 7 * $i + $d + $start_week;
if ($nowday >= $wstar && $mday <= $month) {
$temp = date('d', strtotime($date . '-' . $mday));
echo '<td>'.$temp . '</td>';
$mday++;
} else {
echo '<td> </td>';
}
}
echo '</tr>';
}
echo '</tbody>
</table>';
}
?>
더 많은 PHP 관련 내용 에 관심 이 있 는 독자 들 은 본 사이트 의 주 제 를 볼 수 있다.본 논문 에서 말 한 것 이 여러분 의 PHP 프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
laravel에 yo에서 angularJs&coffeescript를 사용할 수 있도록 한다.먼저 yo 명령을 사용할 수 있어야하므로 아래에서 설치 global에 설치한 곳에서 laravel의 프로젝트 루트로 이동. 클라이언트 코드를 관리하는 디렉토리를 만들고 이동합니다. 클라이언트 환경 만들기 이것으로 히...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.