解讀php生成靜態(tài)頁(yè)面的簡(jiǎn)單實(shí)例_PHP教程
教程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
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁(yè)面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問(wèn)控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語(yǔ)言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國(guó)語(yǔ)言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-解讀php生成靜態(tài)頁(yè)面的簡(jiǎn)單實(shí)例
。