Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php header("Content-Type:text/html;charset=utf-8"); echo"张阎诗文 2333160140"; date_default_timezone_set("PRC"); error_reporting(0); echo "<style>table{margin:0 auto}td{border:1px solid #ccc}</style>"; $year =$_GET['year']; $month =$_GET['month']; if(empty($year)) $year = date("Y"); if(empty($month)) $month = date("n"); $day = date("j"); $wd_ar = array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); $swd = date("w", mktime(0, 0, 0,$month, 1, $year)); $y_link1 = $year <= 1970 ?$year = 1970 : $year - 1; $y_link2 = $year >= 2037 ?$year = 2037 : $year + 1; $m_link1 = $month <= 1 ?$month = 1 : $month - 1; $m_link2 = $month >= 12 ?$month = 12 : $month + 1; echo "<table><tr align=center>"; echo "<td colspan=4><a href='calendar_ext.php?year=$y_lnk1&month=$month'> <</a>" . $year."年<a href='calendar_ext.php?year=$y_lnk2&month=$month'>></a></td>"; echo "<td colspan=3><a href='calendar_ext.php?year=$year&month=$m_lnk1'> <</a>" . $month ."月<a href='calendar_ext.php?year=$year&month=$m_lnk2'>></a></td></tr>"; echo "<tr align=center>"; for ($i = 0;$i < 7; $i++) { echo "<td>$wd_ar[$i]</td>"; } echo "</tr>"; $tnum =$wd + date("t", mktime(0, 0, 0, $month, 1,$year)); for ($i = 0;$i < $tnum;$i++) { $date=$i+1-$wd; if ($i % 7 == 0) echo "<tr align=center>"; //一行的开始 echo"<td>"; if($i>=$wd){ if($date == $day && $month ==date("m") && $year ==date("Y")) echo "<b><font color=red>". $day. "</font></b>"; else echo $date; } echo "</td>"; if ($i % 7 == 6) echo "</tr>"; //一行结束 } echo "</table>"; ?>
Copy Clear