1.index
<?php
require 'public/header.php';
$news = require 'data/news.php';
$items = require 'data/items.php'
?>
<main>
<!-- 新闻列表 -->
<div class="news">
<h3>新闻列表</h3>
<div class="list">
<?php for ($i = 0; $i < 5; $i++) : extract($news[$i]) ?>
<a href="<?= $url ?>"><?= mb_substr($title, 0, 18) ?>...</a>
<?php endfor ?>
</div>
</div>
<div class="items">
<h3>产品列表</h3>
<div class="list">
<?php for ($i = 0; $i < 4; $i++) : extract($items[$i]) ?>
<div class="item">
<img src="<?= $img ?>" alt="">
<a href="<?= $url ?>"><?= mb_substr($title, 0, 18) ?></a>
</div>
<?php endfor ?>
</div>
</div>
</main>
<?php
require 'public/footer.php'
?>
2.items
<?php
require 'public/header.php';
$items = require 'data/items.php'
?>
<main>
<!-- 产品列表 -->
<div class="items">
<h3>产品列表</h3>
<div class="list">
<?php foreach ($items as $item) : extract($item) ?>
<div class="item">
<img src="<?= $img ?>" alt="" />
<?php if (mb_strlen($title) > 20) {
$title = mb_substr($title, 0, 19) . '...';
} ?>
<a href=""><?= $title ?></a>
</div>
<?php endforeach ?>
</div>
</div>
<!-- 分页条 -->
<p class="pagebar">
<a href="">1</a>
<a href="">...</a>
<a href="">6</a>
<a href="">7</a>
<a href="" class="active">8</a>
<a href="">9</a>
<a href="">10</a>
<a href="">...</a>
<a href="">20</a>
</p>
</main>
<?php
require 'public/footer.php'
?>