PHP个人网站架设连环讲(三)
来源:互联网 发布:淘宝适合小个子的女装 编辑:程序博客网 时间:2024/05/08 06:19
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
上次我们做了一个文件头(至于文件尾,请大家自己做,假设为tail.PHP),一个函数的模块,现在,我们来一个基本功能的实现,也就是动态发布啦
<?PHP
include("makestr.PHP";
include("head.PHP");
$newspath="/announce/"; //以文本文件存放的新闻文件的目录
$newsfile=array();//准备新闻数组
$hd=dir($newspath); //目录句柄
while($filename=$hd->read()){ //获取全部文件
$s=strtolower($filename);
if(strstr($s,".txt")){
//检测最新的修改日期
$lastchanged=fileatime($newspath.$filename);
$newsfile[$filename]=$lastchanged;
}
}
arsort($newsfile); //文件按时间排序
//输出文件
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]);//去除空格
$s=htmlspecialchars($s);
print $s."</p>/n";
}
}
$hd->close(); //释放句柄
include("tail.PHP");
?>
这样,将你的新闻文本传上你根目录的annouce子目录下,就可以方便发布新闻了。但真正的方便还不在于这,比如说,当新闻过时的时候,程序能自动删除它,多好。不用ftp,直接在线写下要新发的公告,多方便。好了,且听下回分解。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
三 首页新闻发布,让你更新更轻松(中) 上次我们做了一个文件头(至于文件尾,请大家自己做,假设为tail.PHP),一个函数的模块,现在,我们来一个基本功能的实现,也就是动态发布啦
<?PHP
include("makestr.PHP";
include("head.PHP");
$newspath="/announce/"; //以文本文件存放的新闻文件的目录
$newsfile=array();//准备新闻数组
$hd=dir($newspath); //目录句柄
while($filename=$hd->read()){ //获取全部文件
$s=strtolower($filename);
if(strstr($s,".txt")){
//检测最新的修改日期
$lastchanged=fileatime($newspath.$filename);
$newsfile[$filename]=$lastchanged;
}
}
arsort($newsfile); //文件按时间排序
//输出文件
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]);//去除空格
$s=htmlspecialchars($s);
print $s."</p>/n";
}
}
$hd->close(); //释放句柄
include("tail.PHP");
?>
这样,将你的新闻文本传上你根目录的annouce子目录下,就可以方便发布新闻了。但真正的方便还不在于这,比如说,当新闻过时的时候,程序能自动删除它,多好。不用ftp,直接在线写下要新发的公告,多方便。好了,且听下回分解。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- PHP个人网站架设连环讲(三)
- PHP个人网站架设连环讲(四)
- PHP个人网站架设连环讲(一)
- PHP个人网站架设连环讲(二)
- 初次架设PHP网站
- Dropbox 架设免费个人网站
- 记第一次架设个人网站
- ubuntu下架设php网站
- 如何架设你自己的个人网站
- 如何架设你自己的个人网站
- 三分钟网站架设全过程(视频)
- Openwrt架设网站(uhttpd+php+sqlite)
- 网站架设
- 网站架设
- 架设个人服务器
- 轻松架设个人服务器
- 如何架设个人服务器
- 架设wordpress个人博客
- WIN98下Apache1.3.14+PHP4.0.4的安装
- 看看一个.net版对话框控件
- 程序员路在何方
- php&java(一)
- 一个无刷新效果定时自动更新页面的例子
- PHP个人网站架设连环讲(三)
- ASP.NET2.0,无刷新页面新境界
- PHP个人网站架设连环讲(四)
- AjaxPro让.NET的AjaxPro变得简单
- PHP个人网站架设连环讲(一)
- 如何利用.NETFramework使用RSSfeed
- PHP个人网站架设连环讲(二)
- .NET中如何生成静态页
- 怎样在UNIX系统下安装php3