电脑安全

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

php生成静态页面 html文档类-网络编程

来源:[db:来源]标题:   数组    编辑:电脑技术全能网 时间:2019-09-19 12:33

原标题:php生成静态页面 html文档类-网络编程
   上面咱们来看看用php天生html动态页面的顺序吧,是一个很简略的类哦,好了费话不说多了来看看吧。 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,$Shuzuobj){ //批量调换数组 if(count($Shuzusou)!=count($Shuzuobj)){ exit("调换数组不婚配"); } if($this->AllHtml==""){ exit("没有要调换的内容"); } for($i=0;$i<count($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,$fsize); fclose($file); } //-----------------------------读取文件实现------------------------------ //-----------------------------保留文件--------------------------------- function SaveFile(){ $file=fopen($this->OutUrl,"w"); fwrite($file,$this->AllHtml); fclose($file); } //-----------------------------保留文件实现------------------------------}//------------------------------天生动态的类实现--------------------------------------$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();

上一篇:回复一位PHPER的面试题解答-网络编程

下一篇:没有了