最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 生成静态页面 fopen fwrite
时间:2009-04-15 编辑:简简单单 来源:一聚教程网
function makeHtml($msgContent,$filePath,$fileName){//生成html文件
if(!is_dir($filePath)){@mkdir($filePath);}
$handle = fopen(str_replace('\','../',$filePath.$fileName),'w+') or die("can't create file!$fileName");
fwrite($handle,$msgContent);
fclose($handle);
}
function md5_filename($fileid,$fileztype,$fileuid){//文件加密方法
return md5($fileid.$fileztype.$fileuid).'.htm';
}
function getSql(){//一次多少生成htm文件
global $limit,$start,$id;
$sysType = '';
if( !empty( $id ) ){
$sysType = "And systype = $id";
}
$sql = "select * from filecontent where siteindex=1 $sysType limit $start,$limit";
$result = mysql_query($sql) or die('Query error');
while( $rs = mysql_fetch_array($result) ){
$fileName =md5_filename($rs[0],$rs['z_type'],$rs['filesendid']);
$path = get_path($rs['systype']).$rs['z_type'].'/';
$parent = substr(getcwd(),0,strrpos(getcwd(),'\'));
$filePath =$parent.'\'.$path;
makeHtml($rs['content'],$filePath,$fileName);
}
mysql_free_result($result);
}
$info = "";
if($start>$end){
die('完成所有生成任务!');
} else {
getSql();
echo $info;
}
-
上一个: php 登陆并设置cookie代码
-
下一个: php 文件分页代码 上一页 下一页
相关文章
- php中静态化生成的方法(htm页面生成) 02-27
- php生成静态页面代码 07-24
- php生成静态页面 文章列表问题 06-01
- php 静态化页面 生成静态页面 04-24
- php 生成静态页面 04-24
- PHP生成静态页面 04-01