标题: PHP网页设计Web开辟源代码:PHP生成静态页面的类 [打印本页] 作者: 金色的骷髅 时间: 2015-2-3 23:53 标题: PHP网页设计Web开辟源代码:PHP生成静态页面的类 怎么配置呢 ,问最好的老实百度,问啥都有答案。所以用好搜索引擎是学好的令1个关键,程序会出各样的问题,没有1个人可能会碰到所有的问题,所有就可以问百度这个大家精华的集合了。 class html
{
var $dir; //dir for the htmls(without/)
var $rootdir; //root of html files(without/):html
var $name; //html文件寄存途径
var $dirname; //指定的文件夹称号
var $url; //获得html文件信息的来历网页地址
var $time; //html文件信息填加时的工夫
var $dirtype; //目次寄存体例:year,month,,,,
var $nametype; //html文件定名体例:name
function html($nametype='name',$dirtype='year',$rootdir='html')
function setvar($nametype='name',$dirtype='year',$rootdir='html')
function createdir($dir='')
{
$this->dir=$dir?$dir:$this->dir;
if (!is_dir($this->dir))
{
$temp = explode('/',$this->dir);
$cur_dir = '';
for($i=0;$i {
$cur_dir .= $temp[$i].'/';
if (!is_dir($cur_dir))
}
}
}
function getdir($dirname='',$time=0)
{
$this->time=$time?$time:$this->time;
$this->dirname=$dirname?$dirname:$this->dirname;
switch($this->dirtype)
{
case 'name':
if(empty($this->dirname))
$this->dir=$this->rootdir;
else
$this->dir=$this->rootdir.'/'.$this->dirname;
break;
case 'year':
$this->dir=$this->rootdir.'/'.date("Y",$this->time);
break;
case 'month':
$this->dir=$this->rootdir.'/'.date("Y-m",$this->time);
break;
case 'day':
$this->dir=$this->rootdir.'/'.date("Y-m-d",$this->time);
break;
}
$this->createdir();
return $this->dir;
}
function geturlname($url='')
{
$this->url=$url?$url:$this->url;
$filename=basename($this->url);
$filename=explode(".",$filename);
return $filename[0];
}
function geturlquery($url='')
{
$this->url=$url?$url:$this->url;
$durl=parse_url($this->url);
$durl=explode("&",$durl[query]);
foreach($durl as $surl)
return join("_",$eurl);
}
function getname($url='',$time=0,$dirname='')
{
$this->url=$url?$url:$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;
break;
case 'time':
$this->name=$this->dir.'/'.$this->time.'.htm';
break;
case 'query':
$this->name=$this->dir.'/'.$this->geturlquery().'.htm';
break;
case 'namequery':
$this->name=$this->dir.'/'.$this->geturlname().'-'.$this->geturlquery().'.htm';
break;
case 'nametime':
$this->name=$this->dir.'/'.$this->geturlname().'-'.$this->time.'.htm';
break;
}
return $this->name;
}
function createhtml($url='',$time=0,$dirname='',$htmlname='')
{
$this->url=$url?$url:$this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
//下面包管不反复地把变量付与该类成员
if(empty($htmlname))
$this->getname();
else
$this->name=$dirname.'/'.$htmlname; //失掉name
$content=file($this->url) or die("Failed to open the url ".$this->url." !");;
///////////////关头步---用file读取$this->url