Blogger Information
Blog 31
fans 0
comment 0
visits 18446
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP第4课-PHP的数组实战-九期线上班
Content っ
Original
956 people have browsed it

1.css部分

  1. .header {
  2. background-color: brown;
  3. height: 30px;
  4. }
  5. .nav li {
  6. list-style:none;
  7. min-width:80px;
  8. line-height: 30px;
  9. float: left;
  10. }
  11. .nav li a {
  12. text-decoration: none;
  13. color: white;
  14. }
  15. .nav {
  16. overflow: hidden;
  17. }
  18. .footer {
  19. background-color: #ccddcc;
  20. height: 30px;
  21. display: flex;
  22. justify-content: center;
  23. align-items: center;
  24. }

2.header.php通用头部文件

  1. <?php
  2. //列表数组
  3. $data = [
  4. 'gc' => [
  5. 'title' => '国产好剧',
  6. 'img' => 'static/1.jpg',
  7. 'yp' => [
  8. '倚天屠龙记',
  9. '都挺好',
  10. '如果可以爱'
  11. ],
  12. ],
  13. 'om' => [
  14. 'title' => '欧美猛片',
  15. 'img' => 'static/4.jpg',
  16. 'yp' => [
  17. '阿凡提',
  18. '泰坦尼克号',
  19. '蜘蛛侠'
  20. ],
  21. ],
  22. 'rh' => [
  23. 'title' => '日韩推荐',
  24. 'img' => 'static/7.jpg',
  25. 'yp' => [
  26. '苍井空',
  27. '武藤兰',
  28. '波多野结衣'
  29. ],
  30. ],
  31. ];
  32. //导航数组
  33. $navArr = [
  34. [
  35. 'url' => 'index.php',
  36. 'title' => '首页',
  37. ],
  38. [
  39. 'url' => 'gc.php',
  40. 'title' => '国产好剧',
  41. ],
  42. [
  43. 'url' => 'om.php',
  44. 'title' => '欧美猛片',
  45. ],
  46. [
  47. 'url' => 'rh.php',
  48. 'title' => '日韩推荐',
  49. ]
  50. ];
  51. ?>
  52. <!doctype html>
  53. <html lang="en">
  54. <head>
  55. <meta charset="UTF-8">
  56. <meta name="viewport"
  57. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  58. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  59. <title>影视网站</title>
  60. <link rel="stylesheet" href="static/style1.css">
  61. </head>
  62. <body>
  63. <!-- 头部-->
  64. <div class="header">
  65. <ul class="nav">
  66. <?php
  67. foreach ($navArr as $arr){
  68. echo '<li><a href="' . $arr['url'] . '">' . $arr['title'] . '</a></li>';
  69. }
  70. ?>
  71. </ul>
  72. </div>

3.footer.php通用底部文件

  1. <!--底部版权-->
  2. <div class="footer">
  3. <p class="copyright">Jason版权所有</p>
  4. </div>
  5. </body>
  6. </html>

4.index.php首页文件

  1. <?php
  2. require_once 'header.php';
  3. foreach ($data as $arr){
  4. echo '<h2>' . $arr['title'] . '</h2>';
  5. echo '<ol>';
  6. foreach ($arr['yp'] as $str){
  7. echo '<li>' . $str . '</li>';
  8. }
  9. echo '</ol>';
  10. }
  11. require_once 'footer.php';
  12. ?>

5.gc.php国产好剧文件

  1. <?php
  2. require_once 'header.php';
  3. echo '<h2>' . $data['gc']['title'] .'</h2>';
  4. echo '<img src="' .$data['gc']['img'] . '" alt="">';
  5. echo '<ol>';
  6. foreach ($data['gc']['yp'] as $str){
  7. echo '<li>' . $str . '</li>';
  8. }
  9. echo '</ol>';
  10. require_once 'footer.php';
  11. ?>

6.om.php欧美猛片文件

  1. <?php
  2. require_once 'header.php';
  3. echo '<h2>' . $data['om']['title'] . '</h2>';
  4. echo '<img src="' . $data['om']['img'] . '" alt="">';
  5. echo '<ol>';
  6. foreach ($data['om']['yp'] as $str){
  7. echo '<li>' . $str. '</li>';
  8. }
  9. echo '</ol>';
  10. require_once 'footer.php';
  11. ?>

7.rh.php日韩推荐文件

  1. <?php
  2. require_once 'header.php';
  3. echo '<h2>'. $data['rh']['title'] .'</h2>';
  4. echo '<img src="' . $data['rh']['img'] . '" alt="">';
  5. echo '<ol>';
  6. foreach ($data['rh']['yp'] as $str){
  7. echo '<li>' . $str . '</li>';
  8. }
  9. echo '</ol>';
  10. require_once 'footer.php';
  11. ?>

手写代码




运行效果

Correcting teacher:查无此人查无此人

Correction status:unqualified

Teacher's comments:补上手写
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