php教程--案例10(网页布局)

t195.php

<?php
//case 10 网页布局
//定义常量,防止直接访问引入页面
define('WEBTEST','test1');
?>
<html>
<head>
    <meta charset="UTF-8">
    <title>网页布局</title>
    //样式表
    <style type="text/css" rel="stylesheet">
        .title
        {
            width: 98%;
            height: 100px;
            background-color: #cccccc;
            margin: 3px auto;
            text-align: center;
        }
        .content
        {
            width: 60%;
            height: 600px;
            float: left;
        }

        .content .lst
        {
            width: 90%;
            height: 580px;
            margin: 0 auto;
        }

        .content .lst .pic
        {
            float: left;
            width: 320px;
            height: 160px;
            background-color: #CCCCCC;
            margin: 5px;
            padding: 5px;
        }

        .content .lst .pic img
        {
            width: 300px;
            height: 150px;
            padding: 5px;
        }

        .side
        {
            width: 38%;
            height: 600px;
            float: right;
        }

        .side ul
        {
            list-style: none;
        }

        .side ul li
        {
            text-indent: 20px;
        }

        .side p
        {
            margin: 0;
            padding: 5px;
            font-size: 20px;
            color: #7f7f7f;
        }
        .footer
        {
            width: 98%;
            height: 100px;
            background-color: #cccccc;
            margin: 3px auto;
            text-align: center;
            clear: both;
        }
    </style>
</head>
<body>
    <div class="title">header</div>
    <div class="content"><?php include ('./t196.php');?></div>
    <div class="side"><?php include ('./t197.php');?></div>
    <div class="footer">footer</div>
</body>
</html>

t196.php

<?php
//访问限制
if(!defined('WEBTEST'))
{
    exit('No access!');
}
//图片列表
$books = array('cat.jpg','cat.jpg','cat.jpg','cat.jpg','cat.jpg','cat.jpg');
?>

<div class="lst">
    //:,endforeach是php 7 新语法
    <?php foreach ($books as $book):?>
    <div class="pic">
        <img src="./img/<?php echo $book;?>">
    </div>
    <?php endforeach;?>
    <div style="clear:both"></div>
</div>

t197.php

<?php
//访问限制
if(!defined('WEBTEST'))
{
    exit('No access!');
}

?>

<h2>PHP培训班开训信息</h2>
<ul>
    <?php
    //数组列表
    $arr = array(
        array('PHP基础班','西安--第01期','兰州--第02期','白银--第03期'),
        array('PHP中级班','成都--第11期','重庆--第12期','宁波--第13期'),
        array('PHP高级班','杭州--第31期','上海--第32期','郑州--第33期')
    );
    //数组首个元素放入p标签,其他放入无序列表
    foreach ($arr as $values)
    {
        foreach($values as $k=>$v):
            echo $k > 0 ? "<li>{$v}</li>":"<p>{$v}</p>";
        endforeach;
    }
    ?>
</ul>

 

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虾米大王

有你的支持,我会更有动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值