// 生成静态功能 if ($_GET["tj"] == "html") { $html = << 老马API导航

老马API导航

收集优质API接口与开发工具
您的IP:获取中...
HTML; // 按权重分组查询 $categories = [ '1' => ['name' => '热门推荐', 'class' => 'hot'], '2' => ['name' => '实用工具', 'class' => 'tool'], '3' => ['name' => '媒体资源', 'class' => 'media'], '0' => ['name' => '其他收藏', 'class' => 'other'] ]; foreach ($categories as $weight => $cat) { $result = $db->query("SELECT * FROM $tableName WHERE weight='$weight' ORDER BY id DESC"); $items = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $items[] = $row; } if (count($items) > 0) { $html .= '
'; $html .= '
' . $cat['name'] . '
'; $html .= '
'; foreach ($items as $row) { $html .= << {$row['title']}
{$row['content']}
HTML; } $html .= '
'; } } $html .= << HTML; $file = 'index.html'; file_put_contents($file, $html); echo '
'; echo '查看首页 '; echo '成功生成 index.html!大小:' . filesize($file) . ' bytes
'; }