Home  >  Article  >  Backend Development  >  People's Daily Online Local Leaders Message Board Use text files to create message board tips (Part 1)

People's Daily Online Local Leaders Message Board Use text files to create message board tips (Part 1)

WBOY
WBOYOriginal
2016-07-29 08:33:311915browse

The first thing is to ensure that the text file can be read and written. Before the file is ready to be written, all we have to do is to process the user's message!
This work can be done before submitting the form. We will separate each item of the data obtained with a specific symbol, such as an ampersand. It is worth mentioning that if the submitted data also contains specific characters, then we will have to separate You have your own way to convert it into other forms;
In this way, we get the data in the form:
$str=”aaaaa&bbbbb&ccccc&ddddd”;
Before writing the data to the file, we add
$str=$str.”rn”
Then execute:
$fp=fopen("txt/mytxt.txt","a");
fwrite($fp,$txt);
fclose($fp);
In this way, the data we write is at the end of the file Part
How to make the latest comments appear at the top of the message board?
With the above processing, the data is easy to handle,
$date=file(“txt/mytxt.txt”);
$n=count($date);
for ($I=$n;$I> 0;$I--){
$str=explode(“&”,$date[$I])
.
//Output each item of the $str array.
.
}
This is the latest inserted message Just stay on top.

The above introduces the tips for using text files to create message boards for People's Daily Online Local Leaders Message Board (Part 1), including the content of People's Daily Online Local Leaders Message Board. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn