PHP implements file guestbook
We have talked so much about file processing systems, but we can't even write the most basic thing.
Starting from this section, you will find that you can write more and more things.
Next let’s take a look at the demonstration effect:
The form interface for writing message content in the following interface:
The display interface after leaving a message:
Let’s take a look at thefile structure:
index.php ---Display input box and message content
write.php ---Write data to message.txt
message.txt ---Save chat content
index.php File
' . $username . '内容为' . $content . '时间为' . date('Y-m-d H:i:s', $time); echo '
'; } } ?>基于文件的留言本演示
After looking at the display content just now, we know that when the file is stored:
1. The segments are divided into segments
2. The content is the same as what the user has previously used A special symbol is used to separate it.
Let’s write write.php code to write messages to the file: