电脑安全

您当前的位置:主页 > 电脑安全 >

php生成静态页面的简单实例-网络编程

来源:[db:来源]标题:   片酬    编辑:电脑技术全能网 时间:2019-09-21 18:25

原标题:php生成静态页面的简单实例-网络编程
   一个简略的实例:消息模版文件news_tmp.html:<html><head><title>{title}</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><TABLE border=0 width=767 cellspacing="0" cellpadding="5"> <TR><TD> <div align="center">{news_title}</div> </TD></TR><TR><TD> <div align="center">{news_image}</div> </TD></TR><TR><TD>{news_content}</TD></TR></TABLE></body></html>______________________________________________________________________________________________答7:消息天生文件aaa.php:<?//假定上面信息都来自表单$title="文娱消息---郑秀文预备发布加入文娱圈";$news_title="郑秀文预备发布加入文娱圈";$image_path=array("image/xxx.jpg","image/xxx2.jpg","image/xxx3.jpg");$news_content="奇迹如日方中的郑秀文(Sammi),除是乐坛天后外,亦以五百五十万片酬登上全港片酬最高女星之位......";$fp=@fopen("news_tmp.html","r") or die("没有模版文件或许没有相干权限!");$str=fread($fp,filesize("news_tmp.html"));fclose($fp);______________________________________________________________________________________________答8:$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);if(count($image_path)){for($n=0;$n<count($image_path);$n++)$news_image.="<img src=".$image_path[$n]."><BR>";$str=str_replace("{news_image}",$news_image,$str);}else$str=str_replace("{news_image}","",$str);$fw=fopen($news_filename,"w");fwrite($fw,$str);?><