我正在尝试创建一个简单的产品目录网站,我想为每个产品显示卡片。我试图通过 PHP 模板变量显示卡片,并将名称、img src、价格等作为参数传递给打印卡片的函数。
这是我的index.php代码:
<?php
require('./php/product_card.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- index.css link ref -->
<link rel="stylesheet" href="css/index.css">
<!-- Bootstrap Link Tag -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- FontAwesome Link Tag -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/brands.min.css" integrity="sha512-AMDXrE+qaoUHsd0DXQJr5dL4m5xmpkGLxXZQik2TvR2VCVKT/XRPQ4e/LTnwl84mCv+eFm92UG6ErWDtGM/Q5Q==" crossorigin="anonymous" />
<title>Emmaarz</title>
</head>
<body>
<div class="container">
<div class="row text-center py-6 mt-5">
<?php
product_card("Bed Cover 1", "img_bc/1.jpeg", "Product Description in less than 100 characters (optional)", "399", "299");
product_card("Bed Cover 2", "img_bc/2.jpeg", "Product Description in less than 100 characters (optional)", "599", "399");
?>
</div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</html>
当我只是 echo $prod_name; 时 它显示了我传递的产品的名称,但它在 $prod_card 变量中不起作用。看起来是什么问题?如何才能实现这一点呢?
偶然的你
人到中年有点甜
不负相思意