Dynamic News Implementation and techniques of dynamic news release

WBOY
Release: 2016-07-29 08:33:39
Original
1002 people have browsed it

To build a website of a certain scale, dynamic news releases are essential. There are many ways to implement it. It is recommended to use text files to generate it, which is fast, simple and trouble-free. Well, let's get to work right away.
First, we assume that there is already a folder named "news" under "c://news", which is used to store the text of news. And we assume that the names of these texts are the titles of the news to be published.
1. First, we limit reading the pointer of the folder.
$handle=dir("c://news");
2. Use a while statement to get the pointers of each text file and output them one by one.
while($file=$handle->read())
{
echo $file;
}
3. After completing the operation 2, observe the output of the results from IIS and find that in addition to listing all text files on the page In addition to the name, there will be two more "strange symbols".
.
. .
The origin of these two logos is not the scope of our discussion today, but their appearance will affect the "press release" of our web page, so it is recommended to use an if statement to skip them when displaying.
4. Use chop() to remove the ".txt" after the file name
$filename=chop($file,".");
In this way, $filename[0] is the title of the news we require.
5. After completing the display, you need to make a link. We assume that the file that processes and displays news is show.php;
To summarize the above, we can write the program like this
$handle=dir("c://news");
while($file=$handle-> ;read())
{
if(($file!='.')&&($file!='..'))
{
$filename=chop($file,".");
echo " filename[0] ";
}
?>
The next step is to output text on the web page. Much has been said about this. I won't repeat it again.​

The above introduces the implementation and techniques of dynamic news and dynamic news publishing, including the content of dynamic news. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!