All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
总结asp.net回发或回调参数无效解决方法_[Asp.Net教程]
asp.net,自定义分页控件_[Asp.Net教程]
PHP,会话
初学解惑:关于ASP.NET技术的学习顺序问题_.net资料_编程技术
Asp.net下的对象成员数据绑定器实现_[Asp.Net教程]
ASP.NET之上传文件管理策略_[Asp.Net教程]
PHP获取远程图片并把它保存到本地_[PHP教程]
解决PHP的Failed,opening,required问题_php资料_编程技术
用最有效的方式来扩大你网站的名声_JavaScript技术_编程技术
PHP中数组元素升序、降序及重新排序的函数_[PHP教程]
Reading number is top 10 pictures
身材野火台灣美女1
Angie Chiu vijara myth2
photos of ashlynn brooke(ashlynn brooke的美图)
The sixties of the last century, China is such a kill pig
The world's top ten most beautiful railway station1
牛奶和人奶哪个好?
Hunan province aizhai super-large suspension bridge open to traffic and 4 world first1
两个妞在等世界上最短的火车
西游四格漫画(一)
心有鱼而力不足
Download software ranking
电脑知识及技巧大合集
Boxer's Top ten classic battle9
Unix video tutorial14
Tram sex maniac 2 (H) rar bag4
Tram sex maniac 2 (H) rar bag14
Ashlynn Video3
虚拟机汉化软件
Unix video tutorial1
Ashlynn Video5
功夫熊猫2(上集)
归海一刀 published in(发表于) 2014/2/17 7:38:29 Edit(编辑)
php生成静态页面的简单实例_[PHP教程]

php生成静态页面的简单实例_[PHP教程]

php生成静态页面的简单实例_[PHP教程]

一个简单的实例:
新闻模版文件news_tmp.html:


{title}










{news_title}










{news_image}









{news_content}







______________________________________________________________________
答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 news_image.="
";
str=str_replace("{news_image}",news_image,str);
}else
str=str_replace("{news_image}","",str);
fw=fopen(news_filename,"w");
fwrite(fw,str);
?>



简单演示PHP如何使用模板生成静态页面。

模板文件templets.htm:



{title}


Hello {hello}





PHP文件代码:


title = 'dwww';
hello = 'dwwwcn!';
file = file_get_contents(’templets.htm’);
file = str_replace(array(’{title}’,’{hello}’),array(title,hello), file);
echo file;

?>







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.