用PHP写一个弹窗广告
以下是一个简单的PHP弹窗广告代码:
<!DOCTYPE html>
<html>
<head>
<title>弹窗广告</title>
<style type="text/css">
#ad-container{
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
padding: 20px;
border: 2px solid #ccc;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
z-index: 9999;
}
</style>
</head>
<body>
<?php
// 随机生成一个数,如果是偶数就显示广告弹窗
$random_number = rand(1, 10);
if($random_number % 2 == 0){
echo '<div id="ad-container">这里是广告内容</div>';
}
?>
</body>
</html>
这段代码会随机生成一个1到10之间的数,如果是偶数就会在页面中显示一个弹窗广告。实际使用中,你需要将“这里是广告内容”替换成你的广告内容,并根据需要调整弹窗的样式。
原文地址: https://www.cveoy.top/t/topic/bmKv 著作权归作者所有。请勿转载和采集!