Blogger Information
Blog 25
fans 0
comment 0
visits 10566
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
网站的首页和产品页的动态替换
PHui
Original
694 people have browsed it

1.index

  1. <?php
  2. require 'public/header.php';
  3. $news = require 'data/news.php';
  4. $items = require 'data/items.php'
  5. ?>
  6. <main>
  7. <!-- 新闻列表 -->
  8. <div class="news">
  9. <h3>新闻列表</h3>
  10. <div class="list">
  11. <?php for ($i = 0; $i < 5; $i++) : extract($news[$i]) ?>
  12. <a href="<?= $url ?>"><?= mb_substr($title, 0, 18) ?>...</a>
  13. <?php endfor ?>
  14. </div>
  15. </div>
  16. <div class="items">
  17. <h3>产品列表</h3>
  18. <div class="list">
  19. <?php for ($i = 0; $i < 4; $i++) : extract($items[$i]) ?>
  20. <div class="item">
  21. <img src="<?= $img ?>" alt="">
  22. <a href="<?= $url ?>"><?= mb_substr($title, 0, 18) ?></a>
  23. </div>
  24. <?php endfor ?>
  25. </div>
  26. </div>
  27. </main>
  28. <?php
  29. require 'public/footer.php'
  30. ?>

2.items

  1. <?php
  2. require 'public/header.php';
  3. $items = require 'data/items.php'
  4. ?>
  5. <main>
  6. <!-- 产品列表 -->
  7. <div class="items">
  8. <h3>产品列表</h3>
  9. <div class="list">
  10. <?php foreach ($items as $item) : extract($item) ?>
  11. <div class="item">
  12. <img src="<?= $img ?>" alt="" />
  13. <?php if (mb_strlen($title) > 20) {
  14. $title = mb_substr($title, 0, 19) . '...';
  15. } ?>
  16. <a href=""><?= $title ?></a>
  17. </div>
  18. <?php endforeach ?>
  19. </div>
  20. </div>
  21. <!-- 分页条 -->
  22. <p class="pagebar">
  23. <a href="">1</a>
  24. <a href="">...</a>
  25. <a href="">6</a>
  26. <a href="">7</a>
  27. <a href="" class="active">8</a>
  28. <a href="">9</a>
  29. <a href="">10</a>
  30. <a href="">...</a>
  31. <a href="">20</a>
  32. </p>
  33. </main>
  34. <?php
  35. require 'public/footer.php'
  36. ?>

Correcting teacher:PHPzPHPz

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