Blogger Information
Blog 64
fans 2
comment 1
visits 47047
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
静态网页和动态网页的区别、php模块化案例
Y的博客
Original
1292 people have browsed it

1. 网站从静态到动态的发展历史

  • 从 txt 到了 html
  • 从静态的 html 到动态的 php
    静态网站:内容比较固定,没有数据库的支撑
    动态网站:可以使浏览器和服务器可以交互,所以服务器端根据客户的不同请求动态的生成网页内容

2. php模块化实例一个页面


公共模块config.php

  1. <?php
  2. $title='天堂电影';
  3. $desc='为你收集最好看的片子';
  4. $keywords='电影、电视、综艺、体育';
  5. $navs=['电影','电视','综艺','体育'];
  6. $movies=['战狼','醉拳','长城','我是演说家'];
  7. ?>

index.php

  1. <?php
  2. require __DIR__.'/config.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. <!-- 关键字 -->
  10. <meta name="keywords" content="<?=$keywords?>">
  11. <meta name="description" content="<?=$desc?>">
  12. <title><?=$title?></title>
  13. <style>
  14. .header {
  15. background-color:black;
  16. height:30px;
  17. }
  18. .nav {
  19. overflow:hidden;
  20. }
  21. .nav li {
  22. list-style:none;
  23. min-width:80px;
  24. line-height:30px;
  25. float:left;
  26. }
  27. .nav li a {
  28. text-decoration:none;
  29. color:white;
  30. }
  31. .footer {
  32. height: 30px;
  33. background-color: #636363;
  34. color: white;
  35. text-align: center;
  36. line-height: 30px;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <!-- 导航 -->
  42. <div class="header">
  43. <ul class="nav">
  44. <li><a href="">首页</a></li>
  45. <?php foreach ($navs as $nav): ?>
  46. <li><a href=""><?=$nav?></a></li>
  47. <?php endforeach ?>
  48. </ul>
  49. </div>
  50. <!-- 主体 -->
  51. <div class="mian">
  52. <h2><?=$navs[0] ?></h2>
  53. <?php foreach ($movies as $movie) :?>
  54. <li><a href=""><?=$movie?></a></li>
  55. <?php endforeach?>
  56. </div>
  57. <!-- 底部 -->
  58. <div class="footer">
  59. <p class="copyright">tt<?=$copyright?>&copy; 版权所有</p>
  60. </div>
  61. </body>
  62. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

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