最近学着写PHP,记录一下学习过程。希望开发过程能够帮助大家,也希望能够得到大家的帮助。
开发工具:vscode、phpstudy_pro、VM虚拟机(win7)
写了一个微信小程序的后台管理,前台以后再写。
虚拟机
虚拟机这里有些小毛病,本地测试时页面时高度是760像素,到虚拟机却是450像素。这里没搞明白。
源代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>校园二手商品交易微信小程序</title>
<style>
body {
width: 100%;
height: 100%;
position: relative;
margin: 0px;
padding: 0px;
}
.all {
}
.header {
width: 100%;
height: 50px;
display: flex;
/* justify-content: center; */
align-items: center;
background-color: darkturquoise;
}
.header > .title {
align-content: center;
margin-left: 30px;
}
.header > .title > text {
font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
font-size: 28px;
}
.bodyer {
height: 100vh;
margin-top: 15px;
margin-left: 15px;
margin-right: 15px;
display: flex;
}
.menu {
background-color: #465298;
border-radius: 10px;
flex: 1;
width: 150px;
height: 100%;
}
.menu > ul {
margin: 0;
padding: 0;
}
.menu > ul > div {
width: 100%;
height: 60px;
text-align: center;
justify-content: center;
}
.main {
width: 100%;
height: 100%;
flex: 5;
margin-left: 15px;
padding-right: 15px;
}
/* 状态一: 未被访问过的链接 */
a:link {
text-decoration: none;
color: #fff;
font-size: 28px;
line-height: 60px;
font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
}
/* 状态二: 已经访问过的链接 */
a:visited {
text-decoration: none;
color: #fff;
font-size: 28px;
line-height: 60px;
font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
}
/* 状态三: 鼠标划过(停留)的链接(默认红色) */
a:hover {
text-decoration: none;
color: red;
font-size: 28px;
line-height: 60px;
font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
}
/* 状态四: 被点击的链接 */
a:active {
text-decoration: none;
color: blue;
font-size: 28px;
line-height: 60px;
font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
}
iframe {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="all">
<!--第一部分:header部分-->
<div class="header">
<div class="title">
<text>校园二手商品交易微信小程序</text>
</div>
</div>
<div class="bodyer">
<!--第二部分:导航栏部分-->
<div class="menu">
<ul>
<?php
// 定义导航项目数组
$navItems = [
['label' => '首页', 'url' => 'home.php?page=home'],
['label' => '用户管理', 'url' => 'home.php?page=user'],
['label' => '商品管理', 'url' => 'home.php?page=shop'],
['label' => '订单查询', 'url' => 'home.php?page=order'],
['label' => '活动管理', 'url' => 'home.php?page=home'],
['label' => '聊天客服', 'url' => 'home.php?page=home'],
];
// 循环遍历导航项目数组
foreach ($navItems as $item) {
echo '<div><a href="' . $item['url'] . '">' . $item['label'] . '</a></div>';
}
?>
</ul>
</div>
<!--第三部分:主体部分-->
<div class="main">
<?php
// 根据页面参数加载不同内容
if (isset($_GET['page'])) {
$page = $_GET['page'];
if ($page === 'home') {
echo '<iframe type="text/javascript" src="/html/login.html"></iframe>';
} elseif ($page === 'user') {
echo '<script type="text/javascript" src="/static/image/塘湾湖.png"></script>';
} elseif ($page === 'shop') {
echo '<h1>联系我们</h1>';
echo '<p>这是联系我们页面的内容。</p>';
} elseif ($page === 'order') {
echo '<h1>联系我们</h1>';
echo '<p>这是联系我们页面的内容。</p>';
} else {
echo '<h1>页面不存在</h1>';
echo '<p>抱歉,找不到请求的页面。</p>';
}
} else {
// 默认显示的内容
echo '<h1>欢迎访问我们的网站!</h1>';
echo '<p>请点击导航栏选择页面。</p>';
}
?>
</div>
</div>
</div>
</body>
</html>
有没有大佬指出一下错误,为什么本地和虚拟机会不一样。