Copy Code code 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; 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-------------------------------
Related examples:
Current 1/2 page
12 Next read the full text