PHP personal website set up a series of Talk (iii) _php tutorial

Source: Internet
Author: User
Three first page press release to make your update easier (medium)

The last time we made a file header (as for the end of the file, please do it yourself, assuming tail.php), a function of the module, now, we come to a basic function of the implementation, that is, dynamic release

Include ("makestr.php";
Include ("head.php");
$newspath = "/announce/"; A directory of news files stored as text files
$newsfile =array ();//Prepare News array
$HD =dir ($newspath); Directory handle
while ($filename = $hd->read ()) {//Get all Files
$s =strtolower ($filename);
if (Strstr ($s, ". txt")) {
Detect the latest modification date
$lastchanged =fileatime ($newspath. $filename);
$newsfile [$filename]= $lastchanged;
}
}
Arsort ($newsfile); File sorted by Time
Output file
for (Reset ($newsfile); $key =key ($newsfile); next ($newsfile))
{$fa =file ($newspath. $key);
$n =count ($FA);
echo "

". Date (" D.m.y-h:i:s ". $newsfile [$key])."
\ n ";
for ($i =0; $i < $n; $i = $i + 1) {
$s =chop ($fa [$i]);//Remove space
$s =htmlspecialchars ($s);
Print $s. "

\ n ";

}
}
$HD->close (); Release handle
Include ("tail.php");
?>
In this way, you can easily post news by passing your news text to the annouce subdirectory of your root directory. But the real convenience is not this, for example, when the news is out of date, the program can automatically delete it, how good. Do not use FTP, directly online to write a new announcement, more convenient. Okay, and listen to the tell.

http://www.bkjia.com/PHPjc/316028.html www.bkjia.com true http://www.bkjia.com/PHPjc/316028.html techarticle three first press release to make your update easier (in) the last time we made a file header (as for the end of the file, please do it yourself, assuming tail.php), a function of the module, now ...

  • 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.