以下是一个简单的自用导航网站的 PHP 实现示例:
index.php 文件:
<!DOCTYPE html>
<html>
<head>
<title>自用导航</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
}
.link-container {
display: flex;
flex-wrap: wrap;
}
.link {
width: 200px;
height: 200px;
margin: 10px;
padding: 20px;
background-color: #f2f2f2;
text-align: center;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.link a {
text-decoration: none;
color: #333;
font-weight: bold;
}
</style>
</head>
<body>
<h1>自用导航</h1>
<div class="link-container">
<?php
$links = array(
array('Google', 'https://www.google.com'),
array('Baidu', 'https://www.baidu.com'),
array('GitHub', 'https://github.com'),
// 添加更多的链接
);
foreach ($links as $link) {
echo '<div class="link">';
echo '<a href="' . $link[1] . '">' . $link[0] . '</a>';
echo '</div>';
}
?>
</div>
</body>
</html>
在此示例中,我们使用一个包含链接名称和 URL 的二维数组来存储导航链接。然后,使用 foreach 循环遍历数组,为每个链接生成一个 <div> 元素,并将链接名称和 URL 插入到相应的 HTML 标记中。
你可以根据自己的需求添加更多的链接到 $links 数组中。
上一篇:Php数据找重算法
下一篇:php 类 默认方法
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站