"/>

">

Home >Backend Development >PHP Tutorial >Publishing news is a program for dynamic and real-time publishing of news using text files.

Publishing news is a program for dynamic and real-time publishing of news using text files.

WBOY
WBOYOriginal
2016-07-29 08:34:131056browse

A program for dynamically publishing news in real time, which can automatically arrange the display sequence according to the release time. News files are text files stored in the specified directory. When there is news, the program will automatically display it and arrange it at the beginning of the page.


News


News


< ;div aligh="center">

include( 'locationfilename.php');
function createur1($text){
//Insert your link into the news text file like this
//${http://mysite.ch}
//Or ${http: //mysite.ch|My homepage in}
//Start processing the text file part
$s=$text;
$a=strstr($s,'${');
if ($a){
$b =strstr($a,'}');
if ($b){
$la=strlen($a); $ls=strlen($s);
$s=substr($s,0,$ls -$la);
$a=substr($a,2);
$lb=strlen($b); $la=strlen($a);
$a=substr($a,0,$la- $lb); $b=substr($b,1);
                                                                                              use using using  -                                                        ($ta);
                                                                     $ a;
}; $ s = $ s. "& lt; a href =" ". $ a." "& gt;". $ linktext. "& lt;/a & gt;". ($s);
}
//Modify your news file storage directory here
//Remember, news files must be text files
$newspath="/home/htdocs/test/new/";
//Settings Array
$newsfile=array();
//Set directory handle
$hd=dir($newspath);
//Get all files and store them in the array
while($filename=$hd-> read() ){
$s=strtolower($filename);
if (strstr($s,".txt")){
//Detect the latest modification date
$lastchanged=filemtime($newspath.$filename); F $ NewsFile [$ FILENAME] = $ LastChanged;
}}}
// file sort
Artort ($ Newsfile);
// output files
for (reset ($ newsfile); $ key = key ($ newsf iLe); next($newsfile)){
$fa=file($newspath.$key);
$n=count($fa);
print "";
} $hd->close(); ;
The above introduces the program of dynamic real-time news release using text files, including the content of news release. 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
n";
print "
n";
for($i=0; $i<$n; $i=$i+1){
            $s=chop($fa[$i]);                                                                                                                                                                                                                                    $i=$i ;br>n";
}
print "