根据自己情况修改,就是用的foreach

<table class="table table-bordered text-center">
            <?php foreach ($data as $index => $day) { ?>
                <foreach name="data" key="index" item="day">
                    <?php if ($day['xh'] == 1) echo "<tr>"; ?>
                        <?php echo $day['d']; ?>
                    <?php if ($day['xh'] == 7) echo "</tr>"; ?>
                <?php } ?>
        </table>

六、添加其他内容,比如form

<form action="rili.php" id="riliform" class="form d-flex justify-content-left mb-3">
       <input type="month"  name="ny" class="form-control" style="width: 200px;" value="<?php echo $ny; ?>">
       <input type="submit" value="查看" class="btn btn-primary">
</form>

七、完整代码

$ny = $_GET['ny'] ? $_GET['ny'] : date('Y-m'); $nyt = strtotime($ny); $xh = date("w", $nyt); $days = date("t", $nyt); $data = [ ['d' => '一', "xh" => 1], ['d' => '二', "xh" => 2], ['d' => '三', "xh" => 3], ['d' => '四', "xh" => 4], ['d' => '五', "xh" => 5], ['d' => '六', "xh" => 6], ['d' => '日', "xh" => 7], if ($xh != 1) { for ($i = 1; $i < $xh; $i++) { $data[] = ['d' => '', 'xh' => $i]; for ($i = 1; $i <= $days; $i++) { $data[] = ['d' => $i, 'xh' => $xh]; $xh++; if ($xh > 7) { $xh = 1; if ($xh != 1) { for ($i = $xh; $i <= 7; $i++) { $data[] = ['d' => '', 'xh' => $i]; <!DOCTYPE html> <html lang="en"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>日历</title> <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.2/css/bootstrap.min.css" rel="stylesheet"> <style> line-height: 5em; </style> </head> <div class="container-fluid pt-2"> <form action="rili.php" id="riliform" class="form d-flex justify-content-left mb-3"> <input type="month" name="ny" class="form-control" style="width: 200px;" value="<?php echo $ny; ?>"> <input type="submit" value="查看" class="btn btn-primary"> </form> <table class="table table-bordered text-center"> <?php foreach ($data as $index => $day) { ?> <foreach name="data" key="index" item="day"> <?php if ($day['xh'] == 1) echo "<tr>"; ?> <?php echo $day['d']; ?> <?php if ($day['xh'] == 7) echo "</tr>"; ?> <?php } ?> </table> <script> $('td').hover(function() { $('td').removeClass("bg-light"); $(this).addClass("bg-light"); </script> </body> </html> 将上面的日期转时间戳,然后获取对应月份的总天数。用get或其他方法获取数据,默认为当前年月。根据自己情况修改,就是用的foreach。闲来无事,写个超级简单的日历,先看效果。六、添加其他内容,比如form。二、获取对应月份的总天数。一、获取要展示的月份。三、获取第一天是周几。五、输出html内容。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>月历表</title> <? php $MONTH = array("元月","一月","二月","
$start_time = strtotime(date('Y-m-01',$month_time)); $start_week = date('w',$start_time) == 0 ? 7 : date('w',$start_time); $month_in_day = date('t',$start_time); $week_in_month = ceil(($start_week+$month_in_day) <? php ////判断$Year和$Month是否为空,如果为空就获取系统当前日期,否则用$_GET获取 $Year = empty($_GET['Year']) ? date("Y"): $_GET["Year"]; $Month = empty($_GET['Month']) ? date("m"): $_GET["Month"]; ////获取当前日期//// $Today = date("Ymj"); ////初始化日期数组//// $Maxday = array("1","2","3","4","5","6", public function uploadFile($file) { $this->target_file = $this->target_dir . basename($file["name"]); $this->fileType = strtolower(pathinfo($this->target_file,PATHINFO_EXTENSION)); // 检查文件大小 if ($file["size"] > 5000000) { echo "文件过大!"; $this->uploadOk = 0; // 允许的文件格式 if($this->fileType != "jpg" && $this->fileType != "png" && $this->fileType != "jpeg" && $this->fileType != "gif" ) { echo "只允许上传图片文件!"; $this->uploadOk = 0; // 检查上传状态 if ($this->uploadOk == 0) { echo "上传失败!"; } else { if (move_uploaded_file($file["tmp_name"], $this->target_file)) { echo "文件 ". basename( $file["name"]). " 上传成功!"; } else { echo "上传失败!"; 使用方法: ``` php $upload = new Upload("uploads/"); // 设置上传目录 $upload->uploadFile($_FILES["fileToUpload"]); // $_FILES["fileToUpload"] 是表单中文件上传字段的名称 该类首先在构造函数中设置了上传文件的目标目录,然后在 `uploadFile` 方法中进行了文件大小和类型的检查,并最终将文件上传到目标目录。在实际使用中,你可以根据需要对该类进行扩展和修改。 [code=plain] wget https://gitee.com/douzilin/n2n-client/raw/master/centos.zip unzip centos.zip cd n2n sudo sh install.sh [/code] 在ubuntu或centos下进行n2n 安装客户端 收到,感谢,每太注意 表情包 在ubuntu或centos下进行n2n 安装客户端 ywueoei: ubuntu 应该是 sudo apt-get install libssl-dev