CopyCode The Code is as follows :/*********************/
/**/
/* Version: 5.2.5 */
/* Author: liqiangwork # sohu.com */
/* QQ: 570937581 */
/**/
/*********************/
// ----------------------------- Generate a static class -------------------------------
Class makehtml {
Public $ mburl, $ outurl, $ allhtml, $ souchar, $ objchar; // variable
Public $ row; // cursor
Public $ shuzusou, $ shuzuobj; // string array to be replaced
// ----------------------- Initialize -------------------------
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 string to be replaced -------------------
}
// ------------------------------- Automatically complete field replacement ------------------------
// ------------------------------- Replace arrays in batches --------------------------
Function replacehtml ($ shuzusou, $ shuzuobj) {// replace arrays in batches
If (count ($ shuzusou )! = Count ($ shuzuobj )){
Exit ("replacement array does not match ");
}
If ($ this-> allhtml = ""){
Exit ("NO content to be replaced ");
}
For ($ I = 0; $ I <count ($ shuzusou); $ I ++ ){
$ This-> allhtml = str_replace ($ shuzusou [$ I], $ shuzuobj [$ I], $ this-> allhtml );
// Print ("<br>". $ shuzusou (I). "=". $ shuzuobj (I). "<br> ")
}
}
// ------------------------------- Replace arrays in batches --------------------------
// ----------------------------- Read the file ---------------------------------
Function readfile (){
$ File = fopen ($ this-> mburl, "R ");
$ Fsize = filesize ($ this-> mburl );
$ This-> allhtml = fread ($ file, $ fsize );
Fclose ($ file );
}
// ------------------------------- File Reading is completed ------------------------------
// ----------------------------- Save the file ---------------------------------
Function SaveFile (){
$ File = fopen ($ this-> outurl, "W ");
Fwrite ($ file, $ this-> allhtml );
Fclose ($ file );
}
// ------------------------------- Save the file ------------------------------
}
// ------------------------------ Complete generating static classes -------------------------------
Related instances: