如何在不删除文件的所有其他内容的情况下在 php 中向文件中写入新行?
<?php
if(isset($_POST['songName'])){
$newLine = "\n";
$songName = $_POST['songName'];
$filename = fopen('song_name.txt', "wb");
fwrite($filename, $songName.$newLine);
fclose($filename);
};
?>
Run Code Online (Sandbox Code Playgroud)
这是文件的样子 当前视图
这就是理想视图的样子
我正在为我网站的客户编写电子邮件脚本以确认订单.我遇到一个问题,即电子邮件中显示的订单总数放在新行上,但代码中没有新行.我附上了正在发生的事情的图像.
这是我的代码:
<?php
if(isset($_POST['email']) && isset($_POST['name']) && isset($_POST['order'])) {
$to = $_POST['email'];
$name = $_POST['name'] .",";
$order = $_POST['order'];
$trackingNumber = $_POST['trackingNumber'];
$totalAmount = "Your total was: $".$_POST['totalAmount'];
if(!empty($to) && !empty($name) && !empty($order)) {
$subject = 'From the band.it team ';
$text = "My name is Bobby and I am a part of band.it's fulfillment Team! We recieved your order and are working to process it from our Gainesville, Florida facility. Feel free to reach out to us at any …Run Code Online (Sandbox Code Playgroud)