複製程式碼 程式碼如下:
class html
{
var $dir; //dir for the html /) :html
var $name; //html文件資訊的來源網頁地址
var $time; //html一個時間的時間
var $dirtype 命名方式:name function html($nametype='name',$dirtype='year',$rootdir='html')
{ # ,$dirtype,$rootdir);
}
function setvar($nametype='name',$dirtype='year #) this->rootdir=$rootdir;
$this->dirtype=$dirtype;
# $this->name ='')
{
$this->dir=$dir?$dir:$this->dir;
##
{
$temp =
explode
( )$
for($i=0;$ i
if (!is_dir($cur_dir))
{ ## @mkdir($cur_dir,0777);
## }
}
function getdir($dirname='',$time=0)
## {
$this->time=$time?$time:$this->time; $this->dirname=$dirname?$irname:$0$irname:$dirname); switch($this->dirtype)
{
## $this->dir=$ this->rootdir;
else
$this-> case 'year' :
$this->dir=$this->rootdir.'/'.date("Y",$this->time);
休息;
case 'month':
$this->dir=$this->rootdir.'/'.date("Y-m",$this->time); ### 休息;
case 'day':
$this->dir=$this->rootdir.'/'.date("Y-m-d",$this->time); ### 休息;
}
$this->createdir();
return $this->dir;
}
函數 geturlname($url='')
{
# $1>url=$$
$filename=
basename
($this->url); $filename=explode(".",$filename); 返回$檔案名稱[0];
}
函數 geturlquery($url='')
{
$this>url=$url?url:this=$url>url;
$durl=parse_url($this->url);
$durl=explode("&",$durl[query]);
foreach($durl as $surl)
{
$eurl[]=$gurl[1];
}
return join("_",$eurl);
}
函數 getname($url='',$time=0,$dirname='')
{
this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
$this->getdir();
switch($this->nametype)
{
case 'name':
$filename=$this->geturlname().'.htm';
$this->name=$this->dir.'/'.$filename; ### 休息;
case ‘time’:
$this->name=$this->dir.'/'.$this->time.'.htm'; ### 休息;
case ‘query’:
$this->name=$this->dir.'/'.$this->geturlquery().'.htm'; ### 休息;
case 'namequery':
$this->name=$this->dir.'/'.$this->geturlname().'-'..url0 '.htm'; ### 休息;
case 'nametime':
$this->name=$this->dir.'/'.$this->geturlname().'-'.$this->時間'.$ htm'; ### 休息;
}
return $this->name;
}
函數 createhtml($url='',$time=0,$dirname='',$htmlname='')
{ url?$url:$this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
//上方保證不重複地將變數賦予該類別成員
if(empty($htmlname))
else
$this->name=$dirname.'/'.$htmlname; //取得名稱
$content=file($this->url) or die("無法開啟 url".$this->url."!");
///////////////關鍵步---用文件讀取$this->url
$content=join( " ",$內容);
$fp=@fopen($this->name,"w") 或 die("無法開啟檔案".$this->name。"!");
if(@fwrite($fp,$content))
return true;
else
則已返回 false;
fclose($fp);
}
////////////////以name為名字產生html
function deletehtml($url='',$time=0, $ dirname='')
{
$this->url=$url?$url:$this->url;
$this->time=$time?$time:$this->time;
$this->getname();
if(@unlink($this->name))
return true;
else
則已返回 false;
}
/**
* function::deletedir()
* 刪除目錄
* @param */
函數deletedir($file)
# {
if(is_dir($file))
$handle =
opendir
($file); while(false!==($filename=readdir($handle))) if($filename!="."&&$filename!="..")
this->deletedir($file."/".$filename);
}
closedir($handle);
rmdir($file);
則以true返回;
}else{
unlink($file);
}
}
}
} ##?># }
##}
以上是產生靜態頁面PHP類_PHP編程的詳細內容。更多資訊請關注PHP中文網其他相關文章!