One examples I used: $fpr=fopen("http://localhost/xxx.php?version=".$files_info[3*$i+0]."&part=".$files_info[3*$i+1]."&type=".$files_info[3*$i+2],"r"); $fpw=fopen("2002_".$files_info[3*$i+0]."_".$files_info[3*$i+1].".htm","w"); while(($str=fread($fpr,1023))) fwrite($fpw,$str); fclose($fpw); fclose($fpr);
写成
fopen("##.htm","w")
不就可以了
$fpr=fopen("http://localhost/xxx.php?version=".$files_info[3*$i+0]."&part=".$files_info[3*$i+1]."&type=".$files_info[3*$i+2],"r");
$fpw=fopen("2002_".$files_info[3*$i+0]."_".$files_info[3*$i+1].".htm","w");
while(($str=fread($fpr,1023)))
fwrite($fpw,$str);
fclose($fpw);
fclose($fpr);
//------------------------------------------------------
// 功能:生成静态新闻页面程序
// 编写日期:2002-8-5
//------------------------------------------------------
$news_title= "林敏俐夺冠胜在镇定 嘉碧仪落选有预兆?";
$news_content= " 《二○○二年香港小姐竞选决赛》昨晚顺利结束,赛果爆大冷,由廿一岁的林敏俐登上冠军宝座...... ";
$fp=@fopen("template/news.htm","r") or die("找不到模版文件!");
$str=fread($fp,filesize("template/news.htm"));
fclose($fp);
$news_filename=time().".html"; //生成的新闻文件名
$str=str_replace("{title}",$title,$str);
$str=str_replace("{news_title}",$news_title,$str);
$str=str_replace("{news_content}",$news_content,$str);
$fw=fopen($news_filename,"w");
fwrite($fw,$str);
?>
<head>
<title>{news_title}</title>
</head>
<body>
{news_content}
</body>
</html>
ob_start();//缓冲开始//代码断
....
...
....$info=ob_get_contents(); //得到缓冲区的内容并且赋值给$info
$file=fopen("$filename",'w'); //打开文件
fwrite($file,$info); //写入信息
fclose($file); //关闭文件ob_end_flush();
好像在以前的帖子里面见过:)
我也一直想做一些关于PHP的摸板。以便让界面能和PHP代码分开。
可是一些设计简单的页面还可以,但如果是比较复杂的。(有许多设计的图片,
CSS,动态效果)就不好办了,不得不在HTML中嵌入许多PHP代码。
而且,现在许多做法都是设计与代码分工。设计人员用DREAMWEAR等工具生成HTML界面。程序人员再进行修改,很麻烦,而且维护困难。
不知给位,有何好的见解,请指教一下小弟。多谢!!