PHP用switch语句设计网站主页

本文介绍了一个使用PHP和HTML实现的简单网站主页布局案例。通过switch语句根据URL参数加载不同的页面内容,实现了动态网页的效果。文章展示了完整的源代码及运行结果。

一 PHP脚本

index.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>switch语句的应用</title>
<style type="text/css">
<!--
body {
	background-color: #F1EFEB;
	margin-left: 00px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE4 {
	color: #154049;
	font-size: 13px;
}
a:link {
	text-decoration: none;
	color: #0A323C;
}
a:visited {
	text-decoration: none;
	color: #006600;
}
a:hover {
	text-decoration: none;
	color: #000033;
}
a:active {
	text-decoration: none;
	color: #003366;
}
-->
</style>
</head>
<body><center>
<table width="850" height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="333" height="50">&nbsp;</td>
    <td width="90">&nbsp;</td>
    <td width="71">&nbsp;</td>
    <td width="74">&nbsp;</td>
    <td width="73" align="right">&nbsp;</td>
    <td width="75" class="STYLE4">返回首页</td>
    <td width="83" class="STYLE4">加入收藏</td>
    <td width="51">&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=最新商品">&nbsp;最新商品</a></span></td>
    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=热门商品">&nbsp;热门商品</a></span></td>
    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("推荐商品");?>">推荐商品</a></span></td>
    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>
    <td align="center"><span class="STYLE4"></span></td>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="850" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="196" height="520" align="center" valign="top"><table width="180" height="523" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#F1F1F1">
      <tr>
        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;<a href="index.php?lmbs=最新商品">&nbsp;最新商品</a></span></td>
      </tr>
      <tr>
        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;<a href="index.php?lmbs=热门商品">&nbsp;热门商品</a></span></td>
      </tr>
      <tr>
        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;&nbsp;<a href="index.php?lmbs=<?php echo urlencode("推荐商品");?>">推荐商品</a></span></td>
      </tr>
      <tr>
        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;&nbsp;<a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table></td>
    <td width="600" align="center" valign="top"><table width="595" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" bgcolor="#FFFFFF">
<?php 
switch($_GET[lmbs]){
case "最新商品":
        include "index1.php";
    break;
case "热门商品":
        include "index2.php";
    break;
case "推荐商品":
        include "index3.php";
    break;
case "特殊商品":
        include "index4.php";
    break;
case "":
        include "index4.php";
    break;
}
?></td>
      </tr>
    </table></td>
    <td width="54">&nbsp;</td>
  </tr>
</table>
</center>
</body>
</html>
 
index1.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <imgsrc="images/bg6.jpg"width="508"height="543">
  8. </body>
  9. </html>
index2.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <ahref="index.php?lmbs=新品上市"></a>
  8. <imgsrc="images/bg7.jpg"width="547"height="548">
  9. </body>
  10. </html>
index3.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <a href="index.php?lmbs=<?php echo urlencode("特价区");?>"></a>
  8. <imgsrc="images/bg8.jpg"width="534"height="410">
  9. </body>
  10. </html>
index4.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <imgsrc="images/bg7.JPG"width="538"height="520">
  8. </body>
  9. </html>
二 运行结果

 
三 功能说明
应用switch语句设计网站主页的布局,将网站头、尾文件设置为固定不变的板块、导航条也作为固定板块;而在主显示区中,应用switch语句根据超链接中传递的值不同,显示不同的内容。
本项目采用C++编程语言结合ROS框架构建了完整的双机械臂控制系统,实现了Gazebo仿真环境下的协同运动模拟,并完成了两台实体UR10工业机器人的联动控制。该毕业设计在答辩环节获得98分的优异成绩,所有程序代码均通过系统性调试验证,保证可直接部署运行。 系统架构包含三个核心模块:基于ROS通信架构的双臂协调控制器、Gazebo物理引擎下的动力学仿真环境、以及真实UR10机器人的硬件接口层。在仿真验证阶段,开发了双臂碰撞检测算法轨迹规划模块,通过ROS控制包实现了末端执行器的同步轨迹跟踪。硬件集成方面,建立了基于TCP/IP协议的实时通信链路,解决了双机数据同步运动指令分发等关键技术问题。 本资源适用于自动化、机械电子、人工智能等专业方向的课程实践,可作为高年级课程设计、毕业课题的重要参考案例。系统采用模块化设计理念,控制核心与硬件接口分离架构便于功能扩展,具备工程实践能力的学习者可在现有框架基础上进行二次开发,例如集成视觉感知模块或优化运动规划算法。 项目文档详细记录了环境配置流程、参数调试方法实验验证数据,特别说明了双机协同作业时的时序同步解决方案。所有功能模块均提供完整的API接口说明,便于使用者快速理解系统架构并进行定制化修改。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值