免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 865 | 回复: 0
打印 上一主题 下一主题

生成静态函数 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-02 15:24 |只看该作者 |倒序浏览

function php2html ($url='http://localhost', $htmlFilePath='/tmp/', $htmlFileName='index.html', $logPath='/tmp/', $logName='log.txt')
{
$htmlContent = file_get_contents($url); //将文件读入 $f_index_html 变量
$htmlPathFile = $htmlFilePath . $htmlFileName; //要生成文件及路径 例: "a/index.html"
//die($htmlPathFile);

if (is_file($htmlPathFile))
{
         @unlink($htmlPathFile);//若文件已存在,则删除
}
$handle = fopen ($htmlPathFile, "w"); //打开文件指针,创建文件
if (!is_writable ($htmlPathFile))
{
  $Msg = "文件:" . $htmlPathFile . "不可写,请检查其属性后重试\r\n";
}
else if (!fwrite ($handle, $htmlContent))
{ //将信息写入文件
  $Msg = "生成文件" . $htmlPathFile . "失败\r\n";
}
else
{
  $Msg = "创建文件" . $htmlPathFile . "成功\r\n";
}
$msgPrefix = date("Y-m-d H:i:s");
$logMsg = '(' . $msgPrefix . ')' . $Msg;
$logHandle = fopen ($logPath . $logName, "a+"); //打开日志文件
fwrite ($logHandle, $logMsg);
fclose($logHandle);
fclose ($handle); //关闭指针
}
php2html("
http://www.pmec.net
", "/home/yanjing/public_html/yanjing/html/", "index.html", dirname(__FILE__)."/log/", "log.txt");
?>


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/2326/showart_149733.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP