PHP自动生成月历代码

2016-01-29 14:43 38 1 收藏

PHP自动生成月历代码,PHP自动生成月历代码

【 tulaoshi.com - PHP 】

 

<?php
/* 
Function Written by Nelson Neoh @3/2004. 
For those who wants to utilize this code, please do not remove this remark. 
If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board.  Thank you.

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/php/)

Function usage: calendar(Month,Year)
*/
   
function calendar($MM,$YYYY){
    if($MM=="") $MM = date("m");
    if($YYYY=="") $YYYY = date("Y");
    if(checkdate($MM,1,$YYYY)){
        $stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));
        $days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY));
        $firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY));
        $lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY));
        $printDays = $days;
        $preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY));
        $preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY));
        $nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY));
        $nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));
        print("<table border="1" cellpadding="1" cellspacing="1"");
        print("<tr<th valign="top"<a href="".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$preMonth."&YY=".$preYear.""P</a</th");
        print("<th colspan="5" valign="top"".strftime("%b %Y",mktime (0,0,0,$MM,1,$YYYY))."</th");
        print("<th valign="top"<a href="".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$nextMonth."&YY=".$nextYear.""N</a</th</tr");
        print("<tr style="font-family: Verdana; font-size:x-small"");
        print("<thSun</th<thMon</th<thTue</th<thWed</th<thThu</th<thFri</th<thSat</th</tr");
       
        $currentDays = 1;
        for($a=1;$a<=5;$a++){
            print("<tr align="left" valign="top" style="font-family: Verdana; font-size:x-small"");
            $diffDays = $firstDay-$lastDay;
            if($firstDay$lastDay && $currentDays ==1 && ($diffDays<1)){
                for($x=$lastDay;$x=0;$x--){
                    $printDays = $days-$x;
                    print("<td$printDays</td");
                }
                for($z=1;$z<$firstDay-$lastDay;$z++){
                    print("<td&nbsp;</td");
                }
         &

来源:https://www.tulaoshi.com/n/20160129/1494012.html

延伸阅读
标签: PHP
  What is FPDF? FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. The advantage is that PDFlib requires a fee for a commercial usage. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. FPDF可以...
标签: PHP
  多年前本人开始从事三维动画方面的学习,后学习了PHP,发现可以通过PHP动态生成VRML文档,有点类似于Generator动态生成Flash的方式。   由于VRML博大精深,这里只介绍一个简单的例子,还可以将各种VRML结点存入数据库中,这样的虚拟现实网页将……,爽!   下面是源程序。注意:在服务器上,要将让PHP处理wrl格式的...
标签: 电脑入门
在编辑文档的时候,目录有时是必不可少的一项,但在实际情况当中,很多使用者不知道怎样使用word中的目录自动生成的功能,而是自己在首页手动编制,结果常常因为后面格式或者字体的调整,使得目录与正文出现差距。因此用下面的方法能简单的生动生成: 步骤方法 下面就来介绍一下如何利用word自动生成目录并动态更新。这里介绍两种方法: 一...
标签: Web开发
代码如下: ?php  class html  {      var $dir;        //dir for the htmls(without/)      var $rootdir;    //root of html files(without/):html  &n...
标签: word
word自动生成目录教程   一、把文章排版好,章节需要清晰,如图所示 二、生成大纲。步骤如下:点击工具栏视图 - 大纲视图,依次给章节编上大纲级别 接着 三、本文示例所有章节纲别均为1级,点击工具栏引用 - 目录 -选择自动目录,效果如下: 用word制作数据分析图方法介绍   新建一个word ...

经验教程

82

收藏

59
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部