澳门新莆京手机网站-新蒲京娱乐场 > 书籍 > php 静态文件生成类

php 静态文件生成类

<?php 
switch ($_SERVER["HTTP_HOST"]) { 
    case "www1.aspcn.net": 
        header("location:index1.htm"); 
        break; 
    case "www2.aspcn.net": 
        header("location:index2.htm"); 
        break; 
    case "www3.aspcn.net": 
        header("location:index3.htm"); 
...... 继续累积 ...... 
        break; 

?>

defined('phpjb51') or die(header("http/1.1 403 not forbidden"));

php教程 静态文件生成类
defined('php教程ox') or die(header("http/1.1 403 not forbidden"));           
          
class include_createstatic            
{           
               
    private $htmlpath = '';           
    private $path = '';           
    public $monthpath = '';           
    private $listpath = '';           
    private $content = '';           
    private $filename = '';           
    private $extname = '.html';           
               
    public function createhtml($type,$desname,$content)           
    {           
        $this->htmlpath = getappinf('htmlpath');           
        if (!file_exists($this->htmlpath))           
        {           
            @mkdir($this->htmlpath);           
        }           
        $this->path = $this->htmlpath.$this->monthpath.'/';           
        if (!file_exists($this->path))           
        {           
            @mkdir($this->path);           
        }           
        $this->listpath = $this->htmlpath.'list/';           
        if (!file_exists($this->listpath))           
        {           
            @mkdir($this->listpath);           
        }           
        switch ($type)           
        {           
            case 'index':           
                $this->filename = $desname;           
                break;           
            case 'list':           
                $this->filename = $this->listpath.$desname;           
                break;           
            case 'view':           
                $this->filename = $this->path.$desname;           
                break;           
        }           
        $this->filename .= $this->extname;           
        $this->content = $content;           
    }           
               
    public function write()           
    {           
        $fp=fopen($this->filename,'wb');           
        if (!is_writable($this->filename))           
        {           
            return false;           
        }           
        if (!fwrite($fp,$this->content))           
        {           
            return false;           
        }           
        fclose($fp);           
        return $this->filename;           
    }           
}      

//方法二

if(file_exists("./index.htm"卡塔尔卡塔尔国//看静态index.htm文件是或不是留存
{
$time=time();
//文件纠正时间和后天时光相差?的话,直接导向htm文件,不然重新生成htm
if(time-filemtime("./index.htm")< 600)
{
header("location:classhtml/main.htm");
}
}
//在你的上马处步向ob_start();
ob_start();
//首页内容,便是您的动态部分了
//在结尾插手ob_end_clean(卡塔尔(قطر‎,并把本页输出到贰个变量中
新蒲京娱乐场,$temp=ob_get_contents();
澳门新莆京手机网站,ob_end_clean();
//写入文件
$fp=fopen("./index.htm",'w');
fwrite(fp,temp卡塔尔(قطر‎ or die('写文件破绽百出'卡塔尔国;
//echo"生成html完成!";

本文实例陈诉了php静态文件生成类。分享给大家供我们参照他事他说加以考察。

Copyright © 2015-2019 http://www.carrefourstation.com. 澳门新莆京手机网站-新蒲京娱乐场有限公司 版权所有