【发布时间】:2021-08-19 19:18:06
【问题描述】:
它只是说:
file_get_contents("lot of html"):打开流失败:第 88 行的 C:\xampp\htdocs\timups-html\admin.php 中没有这样的文件或目录
有没有办法将 HTML 放入函数中而不会出错? 这是我的代码:
if (isset($_POST["category"])) {
$Category = $_POST["category"];
$ProductName = $_POST["productname"];
$Description = $_POST["description"];
$optitle = $_POST["optitle"];
$op1 = $_POST["op1"];
$op2 = $_POST["op2"];
$op3 = $_POST["op3"];
$price = $_POST["Price"];
$productno = "SELECT productno FROM productno";
// $header = include 'style/header.php';
$file_destination = 'Categorys/products/4.php';
$script = '<?php'.$header.'?>
<link rel="stylesheet" type="text/css" href="style/style.css" />
<link rel="stylesheet" type="text/css" href="style/style2.css" />
<main class="container">
<!-- Left Column / Headphones Image -->
<div class="left-column">
<img data-image="black" src="../../images/hammer.png" alt="">
<img data-image="blue" src="../../images/hammer.png" alt="">
<img data-image="red" class="active" src="../../images/hammer.png" alt="">
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<span>'.$Category.'</span>
<h1>'.$ProductName.'</h1>
<p>'.$Description.'</p>
</div>
<!-- Product Configuration -->
<div class="product-configuration">
<!-- Cable Configuration -->
<div class="cable-config">
<span>'.$optitle.'</span>
<div class="cable-choose">
<button>'.$op1.'</button>
<button>'.$op2.'</button>
<button>'.$op3.'</button>
</div>
</div>
</div>
<!-- Product Pricing -->
<div class="product-price">
<span>'.$price.'</span>
<a href="#" class="cart-btn">Add to cart</a>
</div>
</div>
</main>';
$content = file_get_contents($script);
file_put_contents('Categorys/products/4.php', $content);
$sql = "UPDATE productno SET productno = productno + 1"
$result = mysqli_query($link, $sql);
}
【问题讨论】:
-
file_get_contents将读取一个文件 - 不像你这里的字符串,所以file_put_contents('Categorys/products/4.php', $script);可能更合适 -
你到底为什么需要
file_get_contents?预期的结果是什么? -
您是否意识到您在浪费人们的时间只是因为您使用了一个功能,甚至没有花时间阅读手册?
标签: php html sql function variables