Khung quảng cáo mã PHP
Điểm nổi bật của mã PHP:
1. Tính linh hoạt: Bạn có thể dễ dàng thay đổi các biến $productTitle, $productDescription, $productImage, và $productLink để quảng cáo sản phẩm khác.
2. Tự động hóa: Thích hợp để tích hợp vào các hệ thống quản lý sản phẩm lớn hơn, nơi dữ liệu sản phẩm được lưu trữ trong cơ sở dữ liệu và lấy ra bằng PHP.
3. Tương thích: Mã này có thể chạy trên các server hỗ trợ PHP và dễ dàng tích hợp với các framework như Laravel hoặc CodeIgniter.
Dưới đây là mã tương tự được viết lại trong PHP, tích hợp động các chi tiết sản phẩm mà bạn có thể thay đổi linh hoạt:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product Advertisement Banner</title>
<style>
.ad-banner {
display: flex;
align-items: center;
justify-content: space-between;
border: 2px solid #ddd;
border-radius: 8px;
padding: 16px;
max-width: 600px;
margin: 20px auto;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
background-color: #f9f9f9;
}
.ad-banner img {
max-width: 150px;
border-radius: 8px;
}
.ad-content {
flex: 1;
margin-left: 16px;
}
.ad-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 8px;
}
.ad-description {
font-size: 14px;
color: #555;
margin-bottom: 12px;
}
.ad-link {
display: inline-block;
padding: 8px 12px;
color: #fff;
background-color: #007bff;
text-decoration: none;
border-radius: 4px;
font-size: 14px;
}
.ad-link:hover {
background-color: #0056b3;
}
</style>
Khung quảng cáo mã PHP
</head>
<body>
<?php
// Example product details
$productTitle = "Máy Massage Đa Năng";
$productDescription = "Máy massage cầm tay với 6 chế độ thư giãn, giảm đau hiệu quả.";
$productImage = "https://via.placeholder.com/150"; // Replace with your product image link
$productLink = "https://shopee.vn/your-product-link"; // Replace with your product page link
?>
<div class="ad-banner">
<!-- Product Image -->
<img src="<?= $productImage ?>" alt="Product Image">
<!-- Product Details -->
<div class="ad-content">
<div class="ad-title"><?= $productTitle ?></div>
<div class="ad-description"><?= $productDescription ?></div>
<a href="<?= $productLink ?>" class="ad-link">Xem chi tiết</a>
</div>
</div>
</body>
</html>
0 nhận xét:
Đăng nhận xét