Home  >  Article  >  Backend Development  >  Convenient and practical PHP to generate static page class non-smarty page 1/2

Convenient and practical PHP to generate static page class non-smarty page 1/2

WBOY
WBOYOriginal
2016-07-29 08:39:101165browse

Copy the code The code is as follows:


/*********************/
/* */
/* Version: 5.2.5 */
/* Author: liqiangwork#sohu.com */
/ * QQ: 570937581 */
/* */
/*********************/
//-------------------------- --Generate static class-------------------------------
class Makehtml{
public $MbUrl,$OutUrl,$ AllHtml,$SouChar,$ObjChar; //Variable
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 string to be replaced------------------
}
//---------- ------------------Automatic replacement by field---------------------
// --------------------------------Batch replace arrays------------------ --------
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 replace");
}
for($i=0;$i$this->AllHtml=str_replace($Shuzusou[$i],$Shuzuobj[$i],$this->AllHtml);
//print("
".$Shuzusou (i)."=".$Shuzuobj(i)."
")
}
}
//---------------------- -------Batch replacement array completed--------------------------
//---------- ------------------Read files------------------------------- -----
function Readfile(){
$file=fopen($this->MbUrl,"r");
$fsize=filesize($this->MbUrl);
$this->AllHtml =fread($file,$fsize);
fclose($file);
}
//---------------------------- -Reading file completed-----------------------------
//--------------------- -----------------save document------------------------------- --
function SaveFile(){
$file=fopen($this->OutUrl,"w");
fwrite($file,$this->AllHtml);
fclose($file);
}
//--------------------------------Save file completed---------------- ---------------
}
//---------------------------------Generate Static class completion----------------------------------


Related examples:

Current page 1/2 12 times One page

The above has introduced the convenient and practical PHP to generate static page non-smarty pages 1/2, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn