<!doctype html>
<html>
<body>
<?php
echo "<h3>your order is processed !!!!</h3> <br>";
$akash = $_POST["tires"];
$akash2 = $_POST["Oil"];
$akash3 = $_POST["plugs"];
$akash4 = $_POST["hello"];
$write = "tires is ".$akash."<br>" ."Oil is " .$akash2."'t" ."Spark plug is " .$akash3."'t". "address is " .$akash4."<br>";
$open = fopen("order.txt","ab");
$write = fwrite($open,$write);
?>
</body>
</html>
尝试/r/n
而不是<br>
(这是一个html标签,不适用于txt)
$write = "tires is ".$akash."'r'n" ."Oil is " .$akash2."'t" ."Spark plug is " .$akash3."'t". "address is " .$akash4."'r'n";
$open = fopen("order.txt","ab");
$write = fwrite($open,$write);
fclose($open);
在我的情况下,输出是:-
tires is sdff
Oil is ddddd Spark plug is fffff address is ggggg
您可能需要在fopen语句中删除"b"。根据手册,选项b是"二进制",这可能是导致错误的原因。