php生成静态页面 html文档类
分类:博客热点

下边咱们来会见用php生成html静态页面包车型客车前后相继吗,是一个很简短的类哦,好了费话不说多了来看看啊。

复制代码 代码如下:
/*********************/
/* */
/* Version : 5.2.5 */
/* Author : liqiangwork#sohu.com */
/* QQ : 570937581 */
/* */
/*********************/
//-----------------------------生成静态的类-------------------------------
class Makehtml{
public $MbUrl,$OutUrl,$AllHtml,$SouChar,$ObjChar; //变量
public $row; //游标
public $Shuzusou,$Shuzuobj; //替换的字符串数组
//-----------------------初始化-------------------------
function __construct(){ //初始化
$this->MbUrl="";
$this->OutUrl="";
$this->AllHtml="";
$this->Sql="";
$this->SouChar="";
$this->ObjChar="";
}
//-----------------------------自动按字段替换---------------------------
function AutoReplace(){
//------------------自动获取要替换的字符串-------------------
$tlen=count($row);
$shuzu1=array();
$shuzu2=array();
if($row){
$i=0;
foreach($row as $key => $value){
$shuzu2[i]威尼斯正规官网,="<=$".$key."$>";
$shuzu1[i]=$value;
$i++;
}
$this->Replacehtml(shuzu2,shuzu1);
}
//------------------自动获取要替换的字符串-------------------
}
//-----------------------------自动按字段替换完结------------------------
//-----------------------------批量替换数组--------------------------
function Replacehtml($Shuzusou,$ShuzuobjState of Qatar{ //批量替换数组
if(count($Shuzusou)!=count($Shuzuobj)){
exit("替换数组不协作"卡塔尔;
}
if($this->AllHtml==""){
exit("未有要替换的故事情节"卡塔尔(قطر‎;
}
for($i=0;$i$this->AllHtml=str_replace($Shuzusou[$i],$Shuzuobj[$i],$this->AllHtml);
//print("
".$Shuzusou(i)."=".$Shuzuobj(i)."
")
}
}
//-----------------------------批量替换数组实现--------------------------
//-----------------------------读取文件---------------------------------
function Readfile(){
$file=fopen($this->MbUrl,"r");
$fsize=filesize($this->MbUrl);
$this->AllHtml=fread($file,$fsize);
fclose($file);
}
//-----------------------------读取文件完结------------------------------
//-----------------------------保存文件---------------------------------
function SaveFile(){
$file=fopen($this->OutUrl,"w");
fwrite($file,$this->AllHtml);
fclose($file);
}
//-----------------------------保存文件完成------------------------------
}
//------------------------------生成静态的类成就-------------------------------

class Makehtml{ public $MbUrl,$OutUrl,$AllHtml,$SouChar,$ObjChar; //变量 public $row; //游标 public $Shuzusou,$Shuzuobj; //替换的字符串数组 //-----------------------最初化------------------------- function __construct(State of Qatar{ //初始化 $this-MbUrl=; $this-OutUrl=; $this-AllHtml=; $this-Sql=; $this-SouChar=; $this-ObjChar=; } //-----------------------------自动按字段替换--------------------------- function AutoReplace(卡塔尔(قطر‎{ //------------------自动获取要替换的字符串------------------- $tlen=count($row卡塔尔国; $shuzu1=array(State of Qatar; $shuzu2=array(State of Qatar; if($row卡塔尔国{ $i=0; foreach($row as $key = $valueState of Qatar{ $shuzu2[i]==$.$key.$; $shuzu1[i]=$value; $i++; } $this-Replacehtml(shuzu2,shuzu1State of Qatar; } //------------------自动获取要替换的字符串------------------- } //-----------------------------自动按字段替换达成------------------------ //-----------------------------批量轮换数组-------------------------- function Replacehtml($Shuzusou,$Shuzuobj卡塔尔国{ //批量替换数组 if(count($ShuzusouState of Qatar!=count($Shuzuobj卡塔尔(قطر‎卡塔尔国{ exit(替换数组不相配State of Qatar; } if($this-AllHtml==卡塔尔国{ exit(未有要替换的原委State of Qatar; } for($i=0;$icount($Shuzusou卡塔尔;$i++卡塔尔{ $this-AllHtml=str_replace($Shuzusou[$i],$Shuzuobj[$i],$this-AllHtml卡塔尔国; //print(br.$Shuzusou(i卡塔尔(قطر‎.=.$Shuzuobj(i卡塔尔.br卡塔尔 } } //-----------------------------批量替换数组达成-------------------------- //-----------------------------读取文件--------------------------------- function Readfile(卡塔尔(قطر‎{ $file=fopen($this-MbUrl,r卡塔尔; $fsize=filesize($this-MbUrl卡塔尔(قطر‎; $this-AllHtml=fread($file,$fsizeState of Qatar; fclose($fileState of Qatar; } //-----------------------------读取文件实现------------------------------ //-----------------------------保存文件--------------------------------- function SaveFile(卡塔尔(قطر‎{ $file=fopen($this-OutUrl,wState of Qatar; fwrite($file,$this-AllHtmlState of Qatar; fclose($file卡塔尔; } //-----------------------------保存文件完结------------------------------}//------------------------------生成静态的类成就--------------------------------------

连带实例:
当前1/2页 12下一页

$MyMake=new Makehtml; $MyMake-MbUrl=News_Show.shtml; $MyMake-Readfile(); $THTml=$MyMake-AllHtml; $shuzu1=array(); $shuzu2=array(); $shuzu1[0]==$keybord$; $shuzu1[1]==$description$; $shuzu1[2]==$title$; $shuzu1[3]==$Title1$; $shuzu1[4]=$=Bid$; $shuzu1[5]=$=Id$; $shuzu1[6]==$Contentb$; $shuzu1[7]=$=BigId$; $shuzu1[8]==$Date$; $shuzu1[9]==$City$; $shuzu1[10]==$SmallId$; $shuzu1[11]==$CityId$; $shuzu1[12]=width=100%; $MyMake-OutUrl=News_show_1.shtml; $shuzu2[0]=数组0; $shuzu2[1]=数组1; $shuzu2[2]=数组2; $shuzu2[3]=数组3; $shuzu2[4]=数组4; $shuzu2[5]=数组5; $shuzu2[6]=数组6; $shuzu2[7]=数组7; $shuzu2[8]=数组8; $shuzu2[9]=数组9; $shuzu2[10]=数组10; $shuzu2[11]=数组11; $shuzu2[12]=width=95%; $MyMake-Replacehtml($shuzu1,$shuzu2); $MyMake-SaveFile();

本文由威尼斯在线注册平台发布于博客热点,转载请注明出处:php生成静态页面 html文档类

上一篇:没有了 下一篇:而小写m则表示月份的数字(带前导0)
猜你喜欢
热门排行
精彩图文