日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

解讀php生成靜態(tài)頁(yè)面的簡(jiǎn)單實(shí)例_PHP教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:如何讓PHP支持?jǐn)帱c(diǎn)續(xù)傳文件
現(xiàn)在的很多服務(wù)器都支持?jǐn)帱c(diǎn)續(xù)傳去下載軟件,同時(shí)很多下載軟件也是斷點(diǎn)續(xù)傳,怎么樣才能讓PHP也能實(shí)現(xiàn)斷電續(xù)傳功能呢?請(qǐng)先看下面的代碼。 fname = './05e58c19552bb26b158f6621a6650899'; fp = fopen(fname,'rb'); fsize = filesize(fname); if (isset(_SER

一個(gè)簡(jiǎn)單的實(shí)例:
新聞模版文件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:
<?
//假設(shè)下面信息都來(lái)自表單
title="娛樂(lè)新聞---鄭秀文準(zhǔn)備宣布退出娛樂(lè)圈";
news_title="鄭秀文準(zhǔn)備宣布退出娛樂(lè)圈";
image_path=array("image/xxx.jpg","image/xxx2.jpg","image/xxx3.jpg");
news_content="事業(yè)如日方中的鄭秀文(Sammi),除是樂(lè)壇天后外,亦以五百五十萬(wàn)片酬登上全港片酬最高女星之位......";
fp=@fopen("news_tmp.html","r") or die("沒(méi)有模版文件或者沒(méi)有相關(guān)權(quán)限!");

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);
?>



簡(jiǎn)單演示PHP如何使用模板生成靜態(tài)頁(yè)面。

模板文件templets.htm:

<html>
<head>
<title>{title}</title>
</head>
<body>
<p>Hello {hello}</p>
</body>
</html>

PHP文件代碼:

<?php

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

?>

 

分享:PHP判斷搜索引擎機(jī)器人Robot
有朋友問(wèn)到如何使用PHP去判斷是否是搜索引擎,其實(shí)PHP有個(gè)很簡(jiǎn)單的方式去實(shí)現(xiàn),通過(guò)_SERVER這個(gè)預(yù)定義變量中的_SERVER['HTTP_USER_AGENT']可以取得訪問(wèn)者的屬性,具體可以看下Diiscuz!是如何判斷搜索引擎的,函數(shù)代碼如下: function getrobot() { if(!defin

來(lái)源:模板無(wú)憂//所屬分類:PHP教程/更新時(shí)間:2010-04-09
相關(guān)PHP教程