Blogger Information
Blog 18
fans 0
comment 0
visits 11556
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0416电影网站案例--五期线上学习班
风行的博客
Original
776 people have browsed it

实现模块化,重复数据做成公共模板,提高访问效率;

案例

1列表模板页

实例

<?php
// 加载头文件
include __DIR__."/public/include/header.php";
//遍历栏目和电影名称

$cate_id=$_GET['cate_id'];

foreach ($cates as $cate) {




	if($cate['cate_id']==$cate_id){
		echo "<h2>{$cate['alias']}</h2>";
		echo '<ol>';
		foreach($movies as $movie){
			if($cate['cate_id']==$movie['cate_id']){
				echo"<li><a href='detail.php?mov_id=".$movie['mov_id']."'>{$movie['name']}</a></li>";
		    }
		}
		echo '</ol>';

	}

}
// 加载尾部文件
include __DIR__."/public/include/footer.php";


?>

运行实例 »

点击 "运行实例" 按钮查看在线实例


2详情模板页

实例

<?php
// 加载头文件
include __DIR__."/public/include/header.php";
//详情页

$mov_id=$_GET['mov_id'];


		foreach($movies as $movie){
			if($movie['mov_id']==$mov_id){
				echo  "<h3>{$movie['name']}</h3>";
        		echo '<img src="public/static/images/'.$movie['image'].'" alt="" width="400">';
        		echo "<p style='text-indent: 2em'>{$movie['detail']}</p>";
			   
		    }
		}

// 加载尾部文件
include __DIR__."/public/include/footer.php";


?>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

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