Blogger Information
Blog 11
fans 0
comment 0
visits 27451
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php作业训练用数组模拟数据库做动态网页网站博客
饮雪煮茶
Original
1095 people have browsed it

php作业训练用数组模拟数据库做动态网页网站博客

综合应用前边知识。
把源码贴如下:

首页效果图

列表页效果图

文章详情页效果图

首页源码

  1. <!-- 头部导航部分 -->
  2. <?php include __DIR__ . './inc/header.php'; ?>
  3. <!-- 循环取出推荐的图文 -->
  4. <?php
  5. /**
  6. * Undocumented function
  7. *
  8. * @param [type] $articles 文章数据
  9. * @param [type] $num 每次取出的文章数量
  10. * @return void
  11. */
  12. function recommadArticle($articles, $num)
  13. {
  14. // $recommadArticle = [];
  15. $i = 0;
  16. foreach ($articles as $article) {
  17. if ($article['is_recommad'] === 1) {
  18. $recommadArticle[] = $article;
  19. $i++;
  20. if ($i === $num) {
  21. break;
  22. }
  23. }
  24. };
  25. return $recommadArticle;
  26. }
  27. $recommadArticles = recommadArticle($articles, 5);
  28. // 随机文章
  29. /**
  30. * Undocumented function
  31. *
  32. * @param [type] $articles 调用文章库
  33. * @param [type] $num 调用随机文章数量
  34. * @return void
  35. */
  36. function randomArticle($articles, $num)
  37. {
  38. $randomArticle = array_rand($articles, $num);
  39. foreach ($randomArticle as $key) {
  40. $randomArticles[] = $articles[$key];
  41. }
  42. return $randomArticles;
  43. }
  44. $randomArticles = randomArticle($articles, 6);
  45. // 取出一定数量的最新文章
  46. function newArticle($articles, $num)
  47. {
  48. $i = 0;
  49. foreach ($articles as $article) {
  50. $newArticles[] = $article;
  51. $i++;
  52. if ($i === $num) {
  53. break;
  54. }
  55. }
  56. return $newArticles;
  57. }
  58. $newArticles = newArticle($articles, 8);
  59. //通过文章cid取出栏目名称
  60. function readCateName($categries, $cid)
  61. {
  62. foreach ($categries as $categry) {
  63. if ($categry['id'] === $cid) {
  64. $categrieName = $categry['name'];
  65. return $categrieName;
  66. }
  67. }
  68. }
  69. ?>
  70. <!-- 页面主体部分 -->
  71. <main>
  72. <div class="container">
  73. <div class="row">
  74. <div class="col-md-8">
  75. <section>
  76. <div class="recommend-pic">
  77. <div class="title"><span>推荐图文</span></div>
  78. <div class="recommend-content">
  79. <?php foreach ($recommadArticles as $recommadArticle) : ?>
  80. <span>
  81. <a href="<?php echo SITE_DOME . '/article.php?id=' . $recommadArticle['id']; ?>"><img src="<?php echo SITE_DOME . $recommadArticle['img']; ?>" alt=""></a>
  82. <a href="<?php echo SITE_DOME . '/article.php?id=' . $recommadArticle['id']; ?>"><?php echo $recommadArticle['title'] ?></a>
  83. </span>
  84. <?php endforeach; ?>
  85. </div>
  86. </div>
  87. <div class="article-list">
  88. <div class="title"><span>最新文章</span></div>
  89. <?php foreach ($newArticles as $newArticle) : ?>
  90. <div class="article-content">
  91. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><img src="<?php echo SITE_DOME . $newArticle['img']; ?>" alt=""></a>
  92. <div class="article-items">
  93. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><?php echo $newArticle['title']; ?></a>
  94. <p><?php echo $newArticle['discript']; ?></p>
  95. <div class="article-tags">
  96. <span>
  97. <i class="glyphicon glyphicon-folder-open"></i>
  98. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><?php echo readCateName($categries, $newArticle['cid']); ?></a>
  99. </span>
  100. <time><i class="glyphicon glyphicon-time"></i> <?php echo $newArticle['time']; ?></time>
  101. <span>
  102. <i class="glyphicon glyphicon-tags"></i>
  103. <?php $tags = explode(',',$newArticle['tags']); ?>
  104. <?php foreach($tags as $k=>$v): ?>
  105. <a href=""><?php echo $v; ?></a>
  106. <?php endforeach; ?>
  107. </span>
  108. </div>
  109. </div>
  110. </div>
  111. <?php endforeach; ?>
  112. </div>
  113. </section>
  114. </div>
  115. <div class="col-md-4">
  116. <aside>
  117. <div class="aside-ad">
  118. <img src="./static/images/1.jpg" alt="">
  119. </div>
  120. <div class="aside-new">
  121. <div class="title"><span>随机文章</span></div>
  122. <div class="new-items">
  123. <?php foreach($randomArticles as $randomArticle) :?>
  124. <span>
  125. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><img src="<?php echo SITE_DOME . $randomArticle['img']; ?>" alt=""></a>
  126. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><?php echo $randomArticle['title']; ?></a>
  127. </span>
  128. <?php endforeach; ?>
  129. </div>
  130. </div>
  131. <div class="aside-tags">
  132. <div class="title"><span>标签云</span></div>
  133. <div class="tags-items">
  134. <a href="">标签</a>
  135. <a href="">标签</a>
  136. <a href="">标签</a>
  137. <a href="">标签</a>
  138. <a href="">标签</a>
  139. <a href="">标签</a>
  140. <a href="">标签</a>
  141. <a href="">标签</a>
  142. <a href="">标签</a>
  143. <a href="">标签</a>
  144. <a href="">标签</a>
  145. </div>
  146. </div>
  147. <div class="aside-link">
  148. <div class="title"><span>友情链接</span></div>
  149. <div class="link-items">
  150. <a href="">友情链接</a>
  151. <a href="">友情链接</a>
  152. <a href="">友情链接</a>
  153. <a href="">友情链接</a>
  154. <a href="">友情链接</a>
  155. <a href="">友情链接</a>
  156. <a href="">友情链接</a>
  157. </div>
  158. </div>
  159. </aside>
  160. </div>
  161. </div>
  162. </div>
  163. </main>
  164. <!-- 页面底部 -->
  165. <?php include "./inc/footer.php" ?>
  166. </body>
  167. </html>

公共头部源码

  1. <?php include __DIR__ . '/config.php'; ?>
  2. <!DOCTYPE html>
  3. <html lang="zh-CN">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <title><?php echo SITE_NAME;?></title>
  9. <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
  10. <link rel="stylesheet" href="<?php echo SITE_DOME ; ?>/static/css/index.css">
  11. </head>
  12. <body>
  13. <header>
  14. <div class="container">
  15. <div class="row">
  16. <div class="col-md-12 self-nav">
  17. <span><?php echo SITE_NAME;?></span>
  18. <a href="<?php echo SITE_DOME;?>" class="active"><i class="glyphicon glyphicon-home"></i>首页</a>
  19. <?php foreach($categries as $categry):?>
  20. <a href="<? echo SITE_DOME . $categry['url'];?>"><i class="glyphicon glyphicon-education"></i><? echo $categry['name'];?></a>
  21. <? endforeach;?>
  22. </div>
  23. </div>
  24. </div>
  25. </header>

公共底部源码

  1. <footer>
  2. </footer>

文章分类页面源码

  1. <!-- 头部导航部分 -->
  2. <?php include __DIR__ . './inc/header.php'; ?>
  3. <?php
  4. $id = $_GET['cid'];
  5. /**
  6. * Undocumented function
  7. *
  8. * @param [type] $articles 文章库
  9. * @param [type] $id 传入cid
  10. * @return void
  11. */
  12. //通过获取get提交栏目id取出当前栏目下文章。
  13. function cateArticle($articles,$id){
  14. foreach ($articles as $article){
  15. if ($article['cid'] === intval($id)){
  16. $cateArticle[] = $article;
  17. }
  18. }
  19. return $cateArticle;
  20. }
  21. $cateArticles = cateArticle($articles,$id);
  22. // 随机文章
  23. /**
  24. * Undocumented function
  25. *
  26. * @param [type] $articles 调用文章库
  27. * @param [type] $num 调用随机文章数量
  28. * @return void
  29. */
  30. function randomArticle($articles, $num)
  31. {
  32. $randomArticle = array_rand($articles, $num);
  33. foreach ($randomArticle as $key) {
  34. $randomArticles[] = $articles[$key];
  35. }
  36. return $randomArticles;
  37. }
  38. $randomArticles = randomArticle($articles, 6);
  39. // 取出一定数量的最新文章
  40. function newArticle($articles, $num)
  41. {
  42. $i = 0;
  43. foreach ($articles as $article) {
  44. $newArticles[] = $article;
  45. $i++;
  46. if ($i === $num) {
  47. break;
  48. }
  49. }
  50. return $newArticles;
  51. }
  52. $newArticles = newArticle($articles, 8);
  53. //通过文章cid取出栏目名称
  54. function readCateName($categries, $cid)
  55. {
  56. foreach ($categries as $categry) {
  57. if ($categry['id'] === $cid) {
  58. $categrieName = $categry['name'];
  59. return $categrieName;
  60. }
  61. }
  62. }
  63. ?>
  64. <!-- 页面主体部分 -->
  65. <main>
  66. <div class="container">
  67. <div class="row">
  68. <div class="col-md-8">
  69. <section>
  70. <div class="article-list">
  71. <div class="title"><span><?php echo $categries[$id-1]['name']; ?></span></div>
  72. <?php foreach ($cateArticles as $cateArticle) : ?>
  73. <div class="article-content">
  74. <a href="<?php echo SITE_DOME . '/article.php?id=' . $cateArticle['id']; ?>"><img src="<?php echo SITE_DOME . $cateArticle['img']; ?>" alt=""></a>
  75. <div class="article-items">
  76. <a href="<?php echo SITE_DOME . '/article.php?id=' . $cateArticle['id']; ?>"><?php echo $cateArticle['title']; ?></a>
  77. <p><?php echo $cateArticle['discript']; ?></p>
  78. <div class="article-tags">
  79. <span>
  80. <i class="glyphicon glyphicon-folder-open"></i>
  81. <a href="<?php echo SITE_DOME . '/article.php?id=' . $cateArticle['cid']; ?>"><?php echo readCateName($categries, $newArticle['cid']); ?></a>
  82. </span>
  83. <time><i class="glyphicon glyphicon-time"></i> <?php echo $cateArticle['time']; ?></time>
  84. <span>
  85. <i class="glyphicon glyphicon-tags"></i>
  86. <?php $tags = explode(',',$cateArticle['tags']); ?>
  87. <?php foreach($tags as $k=>$v): ?>
  88. <a href=""><?php echo $v; ?></a>
  89. <?php endforeach; ?>
  90. </span>
  91. </div>
  92. </div>
  93. </div>
  94. <?php endforeach; ?>
  95. </div>
  96. </section>
  97. </div>
  98. <div class="col-md-4">
  99. <aside>
  100. <div class="aside-ad">
  101. <img src="./static/images/1.jpg" alt="">
  102. </div>
  103. <div class="aside-new">
  104. <div class="title"><span>随机文章</span></div>
  105. <div class="new-items">
  106. <?php foreach($randomArticles as $randomArticle) :?>
  107. <span>
  108. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><img src="<?php echo SITE_DOME . $randomArticle['img']; ?>" alt=""></a>
  109. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><?php echo $randomArticle['title']; ?></a>
  110. </span>
  111. <?php endforeach; ?>
  112. </div>
  113. </div>
  114. <div class="aside-tags">
  115. <div class="title"><span>标签云</span></div>
  116. <div class="tags-items">
  117. <a href="">标签</a>
  118. <a href="">标签</a>
  119. <a href="">标签</a>
  120. <a href="">标签</a>
  121. <a href="">标签</a>
  122. <a href="">标签</a>
  123. <a href="">标签</a>
  124. <a href="">标签</a>
  125. <a href="">标签</a>
  126. <a href="">标签</a>
  127. <a href="">标签</a>
  128. </div>
  129. </div>
  130. <div class="aside-new">
  131. <div class="title"><span>最新文章</span></div>
  132. <div class="new-items">
  133. <?php foreach($newArticles as $newArticle) :?>
  134. <span>
  135. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><img src="<?php echo SITE_DOME . $newArticle['img']; ?>" alt=""></a>
  136. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><?php echo $newArticle['title']; ?></a>
  137. </span>
  138. <?php endforeach; ?>
  139. </div>
  140. </div>
  141. <div class="aside-link">
  142. <div class="title"><span>友情链接</span></div>
  143. <div class="link-items">
  144. <a href="">友情链接</a>
  145. <a href="">友情链接</a>
  146. <a href="">友情链接</a>
  147. <a href="">友情链接</a>
  148. <a href="">友情链接</a>
  149. <a href="">友情链接</a>
  150. <a href="">友情链接</a>
  151. </div>
  152. </div>
  153. </aside>
  154. </div>
  155. </div>
  156. </div>
  157. </main>
  158. <!-- 页面底部 -->
  159. <?php include "./inc/footer.php" ?>
  160. </body>
  161. </html>

文章详情页源码

  1. <!-- 头部导航部分 -->
  2. <?php include __DIR__ . './inc/header.php'; ?>
  3. <?php
  4. $id = $_GET['id'];
  5. $article = $articles[$id];
  6. // 随机文章
  7. /**
  8. * Undocumented function
  9. *
  10. * @param [type] $articles 调用文章库
  11. * @param [type] $num 调用随机文章数量
  12. * @return void
  13. */
  14. function randomArticle($articles, $num)
  15. {
  16. $randomArticle = array_rand($articles, $num);
  17. foreach ($randomArticle as $key) {
  18. $randomArticles[] = $articles[$key];
  19. }
  20. return $randomArticles;
  21. }
  22. $randomArticles = randomArticle($articles, 6);
  23. // 取出一定数量的最新文章
  24. function newArticle($articles, $num)
  25. {
  26. $i = 0;
  27. foreach ($articles as $article) {
  28. $newArticles[] = $article;
  29. $i++;
  30. if ($i === $num) {
  31. break;
  32. }
  33. }
  34. return $newArticles;
  35. }
  36. $newArticles = newArticle($articles, 8);
  37. //通过文章cid取出栏目名称
  38. function readCateName($categries, $cid)
  39. {
  40. foreach ($categries as $categry) {
  41. if ($categry['id'] === $cid) {
  42. $categrieName = $categry['name'];
  43. return $categrieName;
  44. }
  45. }
  46. }
  47. ?>
  48. <!-- 页面主体部分 -->
  49. <main>
  50. <div class="container">
  51. <div class="row">
  52. <div class="col-md-8">
  53. <section>
  54. <div class="breadcrumb">
  55. <i class="glyphicon glyphicon-home"></i><a href="<?php echo SITE_DOME;?>">首页</a><i class="glyphicon glyphicon-menu-right"></i><?php echo readCateName($categries, $article['cid']); ?><i class="glyphicon glyphicon-menu-right"></i>正文
  56. </div>
  57. <div class="article-content">
  58. <h1><?php echo $article['title']; ?></h1>
  59. <span>
  60. <i class="glyphicon glyphicon-folder-open"></i>
  61. <a href=""><?php echo readCateName($categries, $article['cid']); ?></a>
  62. <i class="glyphicon glyphicon-time"></i>
  63. <time><?php echo $article['time'] ?></time>
  64. <i class="glyphicon glyphicon-tags"></i>
  65. <?php $tags = explode(',',$article['tags']); ?>
  66. <?php foreach($tags as $k=>$v): ?>
  67. <a href=""><?php echo $v; ?></a>
  68. <?php endforeach; ?>
  69. </span>
  70. <article>
  71. <?php echo $article['content']; ?>
  72. </article>
  73. </div>
  74. </section>
  75. </div>
  76. <div class="col-md-4">
  77. <aside>
  78. <div class="aside-ad">
  79. <img src="./static/images/1.jpg" alt="">
  80. </div>
  81. <div class="aside-new">
  82. <div class="title"><span>随机文章</span></div>
  83. <div class="new-items">
  84. <?php foreach ($randomArticles as $randomArticle) : ?>
  85. <span>
  86. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><img src="<?php echo SITE_DOME . $randomArticle['img']; ?>" alt=""></a>
  87. <a href="<?php echo SITE_DOME . '/article.php?id=' . $randomArticle['id']; ?>"><?php echo $randomArticle['title']; ?></a>
  88. </span>
  89. <?php endforeach; ?>
  90. </div>
  91. </div>
  92. <div class="aside-tags">
  93. <div class="title"><span>标签云</span></div>
  94. <div class="tags-items">
  95. <a href="">标签</a>
  96. <a href="">标签</a>
  97. <a href="">标签</a>
  98. <a href="">标签</a>
  99. <a href="">标签</a>
  100. <a href="">标签</a>
  101. <a href="">标签</a>
  102. <a href="">标签</a>
  103. <a href="">标签</a>
  104. <a href="">标签</a>
  105. <a href="">标签</a>
  106. </div>
  107. </div>
  108. <div class="aside-new">
  109. <div class="title"><span>最新文章</span></div>
  110. <div class="new-items">
  111. <?php foreach ($newArticles as $newArticle) : ?>
  112. <span>
  113. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><img src="<?php echo SITE_DOME . $newArticle['img']; ?>" alt=""></a>
  114. <a href="<?php echo SITE_DOME . '/article.php?id=' . $newArticle['id']; ?>"><?php echo $newArticle['title']; ?></a>
  115. </span>
  116. <?php endforeach; ?>
  117. </div>
  118. </div>
  119. <div class="aside-link">
  120. <div class="title"><span>友情链接</span></div>
  121. <div class="link-items">
  122. <a href="">友情链接</a>
  123. <a href="">友情链接</a>
  124. <a href="">友情链接</a>
  125. <a href="">友情链接</a>
  126. <a href="">友情链接</a>
  127. <a href="">友情链接</a>
  128. <a href="">友情链接</a>
  129. </div>
  130. </div>
  131. </aside>
  132. </div>
  133. </div>
  134. </div>
  135. </main>
  136. <!-- 页面底部 -->
  137. <?php include "./inc/footer.php" ?>
  138. </body>
  139. </html>

CSS代码

  1. body {
  2. background-color: #f4f4f4;
  3. display: flex;
  4. flex-direction: column;
  5. }
  6. img {
  7. width: 100%;
  8. display: block
  9. }
  10. .title {
  11. border-bottom: 1px solid #eee;
  12. box-sizing: border-box;
  13. display: flex;
  14. }
  15. .title>span {
  16. border-bottom: 2px solid #35AADC;
  17. font-size: 18px;
  18. padding: 0 0 10px 0;
  19. }
  20. /* 头部导航css */
  21. header {
  22. background-color: #333D46;
  23. color: #fff;
  24. height: 50px;
  25. margin-bottom: 15px;
  26. }
  27. header .self-nav {
  28. display: flex;
  29. align-items: center;
  30. }
  31. header .self-nav>span {
  32. font-size: 28px;
  33. margin: 0 15px;
  34. line-height: 50px;
  35. }
  36. header .self-nav>a {
  37. color: #fff;
  38. font-size: 16px;
  39. padding: 0 15px;
  40. height: 50px;
  41. line-height: 50px;
  42. }
  43. header .self-nav>a>i {
  44. font-size: 12px;
  45. margin: 0 5px;
  46. }
  47. header .self-nav>a:hover,
  48. header .self-nav .active {
  49. background-color: #000;
  50. text-decoration: none;
  51. color: #ddd;
  52. }
  53. /* 主体部分css */
  54. main {
  55. overflow-y: scroll;
  56. }
  57. /* 主题部分推荐推文 */
  58. main .recommend-pic {
  59. padding: 20px;
  60. padding-top: 15px;
  61. background-color: #fff;
  62. border: 1px solid #eee;
  63. height: 350px;
  64. }
  65. main .recommend-pic>.recommend-content {
  66. width: 100%;
  67. height: 250px;
  68. margin: 10px 0;
  69. display: grid;
  70. grid-template-columns: 2fr 1fr 1fr;
  71. grid-template-rows: 1fr 1fr;
  72. grid-template-areas: "img1 img2 img3" " img1 img4 img5";
  73. grid-gap: 10px;
  74. }
  75. main .recommend-pic>.recommend-content>span:nth-of-type(1) {
  76. grid-area: img1;
  77. }
  78. main .recommend-pic>.recommend-content>span:nth-of-type(2) {
  79. grid-area: img2;
  80. }
  81. main .recommend-pic>.recommend-content>span:nth-of-type(3) {
  82. grid-area: img3;
  83. }
  84. main .recommend-pic>.recommend-content>span:nth-of-type(4) {
  85. grid-area: img4;
  86. }
  87. main .recommend-pic>.recommend-content>span:nth-of-type(5) {
  88. grid-area: img5;
  89. }
  90. main .recommend-pic>.recommend-content>span>a:last-of-type {
  91. display: none;
  92. }
  93. main .recommend-pic>.recommend-content img {
  94. height: 100%;
  95. }
  96. /* 主题部分文章列表 */
  97. main .article-list {
  98. padding: 20px;
  99. background-color: #fff;
  100. margin-top: 15px;
  101. display: flex;
  102. flex-direction: column;
  103. }
  104. main .article-list>.article-content {
  105. height: 250px;
  106. margin-top: 15px;
  107. display: grid;
  108. grid-template-columns: repeat(2, 1fr);
  109. border: 1px solid #eee;
  110. box-sizing: border-box;
  111. }
  112. main .article-list>.article-content:hover {
  113. box-shadow: 0 0 1px #888;
  114. }
  115. main .article-list>.article-content img {
  116. height: 100%;
  117. }
  118. main .article-list>.article-content>a {
  119. padding: 0 20px 0 0;
  120. overflow: hidden;
  121. }
  122. main .article-list>.article-content>.article-items {
  123. display: flex;
  124. flex-direction: column;
  125. }
  126. main .article-list>.article-content>.article-items>a {
  127. font-size: 18px;
  128. color: #333;
  129. padding-top: 15px;
  130. }
  131. main .article-list>.article-content>.article-items>a:hover {
  132. text-decoration: none;
  133. color: #35AADC;
  134. }
  135. main .article-list>.article-content>.article-items>p {
  136. margin: 10px 0;
  137. color: #555;
  138. }
  139. main .article-list>.article-content>.article-items>.article-tags {
  140. font-size: 12px;
  141. color: #999;
  142. display: flex;
  143. }
  144. main .article-list>.article-content>.article-items>.article-tags>time {
  145. margin: 0 10px;
  146. }
  147. main .article-list>.article-content>.article-items>.article-tags a {
  148. color: #999;
  149. }
  150. main .article-list>.article-content>.article-items>.article-tags a:hover {
  151. text-decoration: none;
  152. }
  153. /* 主体侧边栏css */
  154. main aside>.aside-ad {
  155. padding: 20px;
  156. background-color: #fff;
  157. }
  158. main aside>.aside-new {
  159. padding: 20px;
  160. background-color: #fff;
  161. margin-top: 15px;
  162. }
  163. main aside>.aside-new>.new-items {
  164. display: flex;
  165. flex-direction: column;
  166. }
  167. main aside>.aside-new>.new-items img {
  168. height: 100%;
  169. }
  170. main aside>.aside-new>.new-items>span {
  171. height: 60px;
  172. margin-top: 15px;
  173. border: 1px solid #eee;
  174. display: grid;
  175. grid-template-columns: 1fr 2.5fr;
  176. grid-gap: 15px;
  177. box-sizing: border-box;
  178. overflow: hidden;
  179. }
  180. main aside>.aside-new>.new-items>span>:last-of-type {
  181. color: #555;
  182. padding-top: 10px;
  183. }
  184. main aside>.aside-new>.new-items>span>a:hover {
  185. text-decoration: none;
  186. color: #35AADC;
  187. }
  188. main aside>.aside-tags {
  189. padding: 20px;
  190. background-color: #fff;
  191. margin-top: 15px;
  192. }
  193. main aside>.aside-tags>.tags-items {
  194. display: flex;
  195. flex-flow: row wrap;
  196. padding-top: 15px;
  197. }
  198. main aside>.aside-tags>.tags-items>a {
  199. padding: 3px 8px;
  200. background-color: #35AADC;
  201. color: #fff;
  202. margin: 5px 10px;
  203. border-radius: 3px;
  204. }
  205. /* 友情链接css */
  206. main aside>.aside-link {
  207. padding: 20px;
  208. background-color: #fff;
  209. margin-top: 15px;
  210. }
  211. main aside>.aside-link>.link-items {
  212. display: flex;
  213. flex-direction: column;
  214. padding-top: 10px;
  215. }
  216. main aside>.aside-link>.link-items>a {
  217. height: 30px;
  218. margin: 5px 0;
  219. padding: 5px 10px;
  220. border: 1px solid #eee;
  221. color: #555;
  222. }
  223. main aside>.aside-link>.link-items>a:hover {
  224. text-decoration: none;
  225. color: #35AADC;
  226. }
  227. /* 底部css */
  228. footer {
  229. margin-top: 15px;
  230. background-color: #222222;
  231. height: 80px;
  232. }
  233. /* 文章详情页 */
  234. main .breadcrumb {
  235. display: flex;
  236. align-items: center;
  237. font-size: 12px;
  238. color: #555;
  239. }
  240. main .breadcrumb>i {
  241. font-size: 10px;
  242. margin: 0 10px;
  243. }
  244. main .breadcrumb a {
  245. color: #555;
  246. }
  247. main .article-content {
  248. padding: 20px;
  249. background-color: #fff;
  250. display: flex;
  251. flex-direction: column;
  252. }
  253. main .article-content>h1 {
  254. font-size: 28px;
  255. margin: 10px auto;
  256. }
  257. main .article-content>span {
  258. font-size: 12px;
  259. color: #333;
  260. margin: 20px auto;
  261. display: flex;
  262. align-items: center;
  263. }
  264. main .article-content>span>i {
  265. font-size: 10px;
  266. color: #555;
  267. margin: 0 10px;
  268. }
  269. main .article-content>span>a {
  270. margin: 0 5px;
  271. }
  272. main .article-content>article {
  273. font-size: 1.5rem;
  274. line-height: 2.8rem;
  275. border-top: 1px solid #eee;
  276. padding: 20px 0;
  277. }

数组数据

  1. <?php
  2. // 定义全站常量
  3. const SITE_NAME = '优秀作文网';
  4. const SITE_DOME = 'http://php.io/blog';
  5. $categries = [
  6. ['id'=>1,'name'=>'小学作文','url'=>'/list.php?cid=1'],
  7. ['id'=>2,'name'=>'初中作文','url'=>'/list.php?cid=2'],
  8. ['id'=>3,'name'=>'高中作文','url'=>'/list.php?cid=3'],
  9. ['id'=>4,'name'=>'考试作文','url'=>'/list.php?cid=4']
  10. ];
  11. $articles = [
  12. ['id'=>1,'title'=>'人性最大的善良,是换位思考','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/1.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>1,'time'=>'2020/01/10' ],
  13. ['id'=>2,'title'=>'别在最好的年纪,活得太安逸','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/2.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>1,'time'=>'2020/01/10'],
  14. ['id'=>3,'title'=>'和明白人说话,和踏实人做事,和厚道人谈情','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/3.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>1,'time'=>'2020/01/10'],
  15. ['id'=>4,'title'=>'不念过去,不畏将来,不负余生','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/4.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>2,'time'=>'2020/01/10'],
  16. ['id'=>5,'title'=>'总有人,在等你回家','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/5.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>3,'time'=>'2020/01/10'],
  17. ['id'=>6,'title'=>'不要在乎一城一池的得失','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/6.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>2,'time'=>'2020/01/10'],
  18. ['id'=>7,'title'=>'人性最大的善良,是换位思考','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/7.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>4,'time'=>'2020/01/10'],
  19. ['id'=>8,'title'=>'人性最大的善良,是换位思考','discript'=>'懂得慈悲,近城远山,都是人间。人生海海,谁人不是举步维艰,孤独前往。 但这世界啊,美就美在,有人是照耀他人的光,有人是等待黎明的夜。孤独不会消失,灵魂却可相拥。','tags'=>'灵魂,善良,孤独人性,换位思考','img'=>'/static/images/8.jpg','is_recommad'=>1,'content'=>'人间百态,各有所难杨绛先生曾写过一句话:“当你身居高位时,看到的都是浮华春梦;当你身处卑微,才有机缘看到世态真相。” 人间百态,各有所难,每个人只看到自己眼中的世界,看不到全貌。 生而为人,最可怕的就是:你生活在光亮里,就认为整个世界都是光亮的。','cid'=>1,'time'=>'2020/01/10']
  20. ];
  21. ?>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:写得不错, 但是有一些重要的数据 , 还是要给出注释的, 以方便阅读,例如常量: SITE_DOME
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post