var $fileName; var $mod; var $handle;

function Shtml($fileName="") { $this->fileName= " /> 欧美本精品男人aⅴ天堂,亚洲欧美资源在线,亚洲国产精品成人

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP靜態(tài)類

復(fù)制代碼 代碼如下:<?php  
class Shtml  
 {  
 var $Templet;  
 var $DataSource;  
 var $Dir;  

 var $fileName;  
 var $mod;  
 var $handle;  

 function Shtml($fileName="")  
 {  
 $this->fileName=$fileName;  
 $this->mod="wb";  
 $this->handle=false;  

 $this->Templet = "";  
 $this->DataSource = array();  
 $this->Dir = "";  
 }  

 /// <描述>  
 /// 綁定數(shù)據(jù)源,參數(shù)為一數(shù)組。  
 /// </描述>  
 function BindData($arr)  
 {  
 $this->DataSource = $arr;  
 }  

 /// <描述>  
 /// 設(shè)置文件存放路徑。  
 /// </描述>  
 function SetDir($dir)  
 {  
 $this->Dir = $dir;  
 }  
 function SetFileName($fileName)  
 {  
 return $this->fileName=$fileName;  
 }  

 function GetMod()  
 {  
 return $this->mod;  
 }  
 function SetMod($mod)  
 {  
 return $this->mod=$mod;  
 }  
 function Open()  
 {  
 if(substr($this->fileName,0,1)=="/")  
 $this->fileName = $_SERVER['DOCUMENT_ROOT'] . $this->fileName;  
 if($this->handle=fopen($this->fileName, $this->mod))  
 return $this->handle;  
 else  
 return false;  
 }  
 function Close()  
 {  
 return fclose($this->handle);  
 }  
 function Write($content)  
 {  
 return fwrite($this->handle,$content);  
 }  
 function MkDir($pathname)  
 {  
 $currentPath="";  
 str_replace("/","/",$pathname);  
 $pathArr = split("/",$pathname);  
 if($pathArr[0] == "") //使用絕對(duì)路徑  
 {  
 $currentPath = $_SERVER['DOCUMENT_ROOT'];  
 }  
 else  
 {  
 $currentPath = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['php_SELF']);  
 }  
 for($i=0; $i<count($pathArr); $i++)  
 {  
 if($pathArr[$i]=="")  
 continue;  
 else  
 if(is_dir($currentPath . "/" . $pathArr[$i]))  
 $currentPath = $currentPath . "/" . $pathArr[$i];  
 else  
 mkdir($currentPath = $currentPath . "/" . $pathArr[$i]);  
 }  
 }  

 /// <描述>  
 /// 生成靜態(tài)文件。  
 /// </描述>  
 function Create()  
 {  
 $tmp = $this->Templet;  
 foreach($this->DataSource as $key=>$value)  
 {  
 $tmp = str_replace("<FIELD_" . $key . ">", $value, $tmp);  
 }  
 $this->MkDir(dirname($this->fileName));  
 $this->Open();  
 $this->Write($tmp);  
 $this->Close();  
 }  
 }  

 function CreateShtml()  
 {  
 ob_start("callback_CteateShtml");  
 }  
 function callback_CteateShtml($buffer)  
 {  
 $page = intval(@$_REQUEST["page"]);  
 $shtml = new Shtml();  
 $shtml->SetFileName($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['php_SELF']) . "/" . basename($_SERVER['php_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm");  
 $shtml->Templet = $buffer;  
 $shtml->Create();  
 return $buffer;  
 }  
?>

php技術(shù)PHP靜態(tài)類,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 平安县| 潍坊市| 吴忠市| 毕节市| 诏安县| 天门市| 舞钢市| 调兵山市| 资阳市| 怀安县| 伊宁县| 布尔津县| 河西区| 曲阜市| 吐鲁番市| 平远县| 慈溪市| 邓州市| 乌鲁木齐市| 高密市| 阿克陶县| 五大连池市| 建平县| 象山县| 南开区| 丘北县| 焦作市| 石家庄市| 襄垣县| 泸州市| 石景山区| 西林县| 太湖县| 大埔县| 二连浩特市| 吴堡县| 榆社县| 崇信县| 左权县| 赤城县| 永宁县|