Class makehtml{
Public $MbUrl, $OUTURL, $AllHtml, $SouChar, $ObjChar; Variable
Public $row; Cursor
Public $Shuzusou, $Shuzuobj; Array of substituted strings
-----------------------initialization-------------------------
function __construct () {//initialization
$this->mburl= "";
$this->outurl= "";
$this->allhtml= "";
$this->sql= "";
$this->souchar= "";
$this->objchar= "";
}
-----------------------------automatically replace by field---------------------------
function Autoreplace () {
------------------automatically gets the string to replace-------------------
$tlen =count ($row);
$shuzu 1=array ();
$shuzu 2=array ();
if ($row) {
$i = 0;
foreach ($row as $key => $value) {
$shuzu 2[i]= "<=$". $key. " $> ";
$shuzu 1[i]= $value;
$i + +;
}
$this->replacehtml (SHUZU2,SHUZU1);
}
------------------automatically gets the string to replace-------------------
}
-----------------------------automatically replaced by field------------------------
-----------------------------Bulk Substitution Array--------------------------
function replacehtml ($Shuzusou, $Shuzuobj) {//Bulk substitution array
if (count ($Shuzusou)!=count ($Shuzuobj)) {
Exit ("Replace array mismatch");
}
if ($this->allhtml== "") {
Exit ("No content to replace");
}
for ($i =0; $i <count ($Shuzusou); $i + +) {
$this->allhtml=str_replace ($Shuzusou [$i], $Shuzuobj [$i], $this->allhtml);
Print ("<br>". $Shuzusou (i). " = ". $Shuzuobj (i)." <br> ")
}
}
-----------------------------The batch substitution array is completed--------------------------
-----------------------------Read the file---------------------------------
function Readfile () {
$file =fopen ($this->mburl, "R");
$fsize =filesize ($this->mburl);
$this->allhtml=fread ($file, $fsize);
Fclose ($file);
}
-----------------------------Read the file is complete------------------------------
-----------------------------Save the file---------------------------------
function SaveFile () {
$file =fopen ($this->outurl, "w");
Fwrite ($file, $this->allhtml);
Fclose ($file);
}
-----------------------------Save file is complete------------------------------
}
------------------------------generate a static class complete--------------------------------------
$MyMake =new makehtml;
$MyMake->mburl= "news_show.shtml";
$MyMake->readfile ();
$THTML = $MyMake->allhtml;
$shuzu 1=array ();
$shuzu 2=array ();
$shuzu 1[0]= "<= $keybord $>";
$shuzu 1[1]= "<= $description $>";
$shuzu 1[2]= "<= $title $>";
$shuzu 1[3]= "<= $Title 1$>";
$shuzu 1[4]= "<$=Bid$>";
$shuzu 1[5]= "<$=Id$>";
$shuzu 1[6]= "<= $Contentb $>";
$shuzu 1[7]= "<$=BigId$>";
$shuzu 1[8]= "<= $Date $>";
$shuzu 1[9]= "<= $City $>";
$shuzu 1[10]= "<= $SmallId $>";
$shuzu 1[11]= "<= $CityId $>";
$shuzu 1[12]= "width=" 100% "";
$MyMake->outurl= "news_show_1.shtml";
$shuzu 2[0]= "Array 0";
$shuzu 2[1]= "Array 1";
$shuzu 2[2]= "Array 2";
$shuzu 2[3]= "Array 3";
$shuzu 2[4]= "Array 4";
$shuzu 2[5]= "Array 5";
$shuzu 2[6]= "Array 6";
$shuzu 2[7]= "Array 7";
$shuzu 2[8]= "Array 8";
$shuzu 2[9]= "Array 9";
$shuzu 2[10]= "Array 10";
$shuzu 2[11]= "Array 11";
$shuzu 2[12]= "width=" 95% "";
$MyMake->replacehtml ($shuzu 1, $shuzu 2);
$MyMake->savefile ();