【发布时间】:2021-04-02 10:08:14
【问题描述】:
我有一个简单的聊天系统,我想做的是将新消息放在 html 之上。我的脚本将新消息放在底部,我想更改它。
<?php
session_start();
if(isset($_SESSION['name'])){
$text = $_POST['text'];
$text_message = "<div class='msgln'><span class='chat-time'>".date("m.d.y")."</span><br> <b
class='user-name'>".$_SESSION['name']."</b> ".stripslashes(htmlspecialchars($text))."<p></div>";
file_put_contents("../log.html", $text_message, FILE_APPEND | LOCK_EX);
}
?>
脚本在干净的 log.html 文件上打印文本
【问题讨论】:
-
您需要在文件开头添加新数据。现在您将其附加到末尾。有一个相关的问题:stackoverflow.com/questions/3332262/…