The realization and technique of dynamic news release

Source: Internet
Author: User
Keywords The realization and technique of dynamic news release
Tags chop
Do the site to do has a certain scale, dynamic news release is essential. There are many ways to do this, and it is recommended to use a text file to generate it quickly and easily. Well, let's get down to work right away.
First, let's assume that there is already a folder named "News", under "C://news", to store the text of the news. And we assume that the name of the text is the title of the news you want to publish.
1, first, we limit the reading of the folder pointer.
$handle =dir ("C://news");
2, using a while statement, gets a pointer to each text file and outputs it one by one.
while ($file = $handle->read ())
{
Echo $file;
}
3, when the completion of the 2 operation, from the output of IIS observation, found on the page in addition to listing all the text file name, there will be more than two "strange symbols."

。。
The source of these two identities is not the scope of our discussion today, but their presence will affect the "press release" of our web page, so it is recommended to skip them with an if statement when they are displayed.
4, use Chop () to remove the ". txt" after the file name
$filename =chop ($file, ".");
In this way, $filename [0] is the headline of the news we asked for.
5, after the completion of the display will be linked. We assume that the document that handles the display of news is show.php;
Summing up above, we can write programs like this
$handle =dir ("C://news");
while ($file = $handle->read ())
{
if ($file! = '. ') && ($file! = ' ... '))
{
$filename =chop ($file, ".");
echo "Filename[0]";
}
?>
After that, the output of the text on the Web page is working, which is a lot of instructions. I will not repeat it.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.