php生成靜態(tài)所要到的類

          <?php
          /*
          Author:DreamFight
          使用方法
          $shtml = new Shtml($Url,$FileBag,$FolderName,$fileid)
          $Url: 頁面 URL 地址
          $FileBag: 文件夾標記 1 為:指定文件夾
          2為:默認文件夾(時間(年月日))
          $FolderRoot html文件存放路徑
          $FolderName 指定文件夾的名稱 $FileBag為2時 可以寫為空("");
          $fileid 靜態(tài)頁面名稱(后綴 默認為 .html)
           */
          ?>
          class Shtml
          {
          var $message1="Error 1: You write class Shtml is Wrong ! The second parameter is 1 or 2 in this class!.";
          var $message2="Error 2: The file write Error.";


          function __construct ($Url,$FileBag,$FolderRoot,$FolderName,$fileid)
          {
          $this->Url = $Url;
          $this->FileBag = $FileBag;
          $this->FileRoot = $FolderRoot;
          $this->FileName = $FolderName;
          $this->fileid = $fileid;
          Shtml::useFolder ();
          }

          /*************獲取數據*******************/
          public function loadcontent ($Folder)
          {
          ob_start();
          require_once $this->Url;
          Shtml::writehtml ($Folder,ob_get_contents());
          ob_clean();
          }

          /********** 指定文件夾*****************/
          public function useFolder ()
          {
          if($this->FileBag==1)
          {
          $Folder=$this->FileName;
          }
          else if($this->FileBag==2)
          {
          $Folder=date('Ymd',time());
          }
          else
          {
          exit($this->message1);
          }
          if(!is_dir($this->FileRoot.$Folder)){ mkdir($this->FileRoot.$Folder,0700);}

          Shtml::loadcontent ($Folder);

          }
          /********** 生成靜態(tài)頁面*****************/
          public function writehtml ($Folder,$cache_value)
          {
          $file = fopen($this->FileRoot.$Folder.'/'.$this->fileid.'.html','w+');
          fwrite($file,$cache_value);
          fclose($file);
          }

          }

          posted on 2008-12-15 02:06 丁克設計 閱讀(196) 評論(0)  編輯  收藏 所屬分類: PHP技術文檔

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          留言簿(6)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 大新县| 怀仁县| 海口市| 景东| 鄂托克旗| 比如县| 大埔区| 射阳县| 额敏县| 洮南市| 永兴县| 当阳市| 绵竹市| 威远县| 海口市| 胶州市| 长沙县| 永嘉县| 凭祥市| 平和县| 百色市| 兰考县| 家居| 平塘县| 台中市| 涟源市| 伊金霍洛旗| 松阳县| 香河县| 淮滨县| 兴海县| 浙江省| 溆浦县| 德江县| 大城县| 兴化市| 桐乡市| 射阳县| 玉环县| 七台河市| 嵊泗县|