PHP personal website set up a serial talk (c)

Source: Internet
Author: User
Tags date array include newsfile root directory
Three first page press release, make your update easier (middle)

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

<?php
Include ("makestr.php";
Include ("head.php");
$newspath = "/announce/"; Directory of news files stored in a text file
$newsfile =array ()//Prepare news array
$HD =dir ($newspath); Table of Contents 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); Sort files by Time
Output file
for (Reset ($newsfile); $key =key ($newsfile); next ($newsfile))
{$fa =file ($newspath. $key);
$n =count ($FA);
echo "<p>". Date ("D.m.y-h:i:s". $newsfile [$key]). " <br>\n ";
for ($i =0; $i < $n; $i = $i + 1) {
$s =chop ($fa [$i]);//Remove spaces
$s =htmlspecialchars ($s);
Print $s. " </p>\n ";

}
}
$HD->close (); Release handle
Include ("tail.php");
?>
This way, you can publish your news text to the annouce subdirectory of your root directory. But the real convenience is not this, for example, when the news is outdated, the program can automatically delete it, how good. Do not use FTP, directly online write down to the new post, more convenient. Okay, and listen to let's.


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.