Copy code The code is as follows:
/*********************/
/* */
/* Version : 5.2.5 */
/* Author : liqiangwork#sohu.com */
/* QQ : 570937581 */
/* */
/*********************/
//--------------------------------Generate static classes------------- ------------------
class Makehtml{
public $MbUrl,$OutUrl,$AllHtml,$SouChar,$ObjChar; //Variables
public $ row; //Cursor
public $Shuzusou,$Shuzuobj; //Replaced string array
//---------------------- Initialization-------------------------
function __construct(){ //Initialization
$this->MbUrl="";
$this->OutUrl="";
$this->AllHtml="";
$this->Sql="";
$this->SouChar=" ";
$this->ObjChar="";
}
//-------------------------- ---Automatically replace by field---------------------------
function AutoReplace(){
//--- ---------------Automatically obtain the string to be replaced------------------
$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);
}
//------------------Automatically obtain the replacement String of -------------------
}
//------------------- ----------Automatically replace by field---------------------
//------ -----------------------Batch replace arrays--------------------- --
function Replacehtml($Shuzusou,$Shuzuobj){ //Batch replacement array
if(count($Shuzusou)!=count($Shuzuobj)){
exit("Replacement array does not match" );
}
if($this->AllHtml==""){
exit("No content to replace");
}
for($i=0 ;$i$this->AllHtml=str_replace($Shuzusou[$i],$Shuzuobj[$i],$this->AllHtml);
//print("
".$Shuzusou(i)."=".$Shuzuobj(i)."
")
}
}
//-- -------------------------------Batch replacement of arrays completed------------------ -------
//--------------------------------Read file------ -----------------------------
function Readfile(){
$file=fopen($this->MbUrl, "r");
$fsize=filesize($this->MbUrl);
$this->AllHtml=fread($file,$fsize);
fclose($file);
}
//--------------------------------Reading file completed--------- ---------------------
//------------------------ -----Save file---------------------------------
function SaveFile(){
$file=fopen($this->OutUrl,"w");
fwrite($file,$this->AllHtml);
fclose($file);
}
//--------------------------------Save file completed---------------- -------------
}
//-------------------------- ---Complete generating static classes-------------------------------
Related examples :
http://www.bkjia.com/PHPjc/319586.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319586.htmlTechArticleCopy the code as follows: /*********************/ /* */ /* Version: 5.2.5 */ /* Author : liqiangwork#sohu.com */ /* QQ : 570937581 */ /* */ /*********************/ //------------...