| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 823 人关注过本帖
标题:求助,php生成静态网页问题
只看楼主 加入收藏
shenyulv
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:166
专家分:150
注 册:2009-3-8
结帖率:96.43%
收藏
 问题点数:0 回复次数:1 
求助,php生成静态网页问题
用php生成静态网页,以下是源代码:

<?php
 function phptohtml($in_url,$out_htmlfile,$out_logfile)
 {
    $htmlcontent=file_get_contents(in_url);//将文件读入变量中
    if(is_file($out_htmlfile))
    {
      @unlink($out_htmlfile);//检查文件是否存在,若存在则先删除
      }
      //创建目录,网页部分
  $dir_array=explode("/",dirname($out_htmlfile));
   chdir("/");
   for($i=1;$i<count($dir_array);$i++)
   {
   if(is_dir(dir_array[$i]))
   {
     chdir($dir_array[$i]);
     }
     else
     {
      mkdir($dir_array[$i]);
      chdir($dir_array[$i]);
      }
     }
   
     //创建目录,日志部分
  $dir_array=explode("/",dirname($out_logfile));
   chdir("/");
   for($i=1;$i<count($dir_array);$i++)
   {
   if(is_dir(dir_array[$i]))
   {
     chdir($dir_array[$i]);
     }
     else
     {
      mkdir($dir_array[$i],0777);
      chdir($dir_array[$i]);
      }
     }
   
     $handle=fopen($out_htmlfile,"w");//打开文件指针,创建文件
     $loghandle=fopen($out_logfile,"a+");
   
   
     //检查目录是否可写
   
    if(!is_writable($out_htmlfile))
    {
     echo"文件不可写,请检查目录属性后重试";
     exit();
     }
   
    if(!is_writable($out_logfile))
    {
     echo"文件不可写,请检查目录属性后重试";
     exit();
     }   
   
     //写入文件
     if(!fwrite($handle,$out_htmlfile)
     {
       $logmsg="写入文件".$out_htmlfile."失败";
      }
     
      else
     
      {
     
         $logmsg="创建文件".$out_htmlfile."成功";
     }
   
   
     //记录日志
   
     $logmsg .="(".date("Y-m-d,H:i:s").")\r\n";
     fwrite($loghandle,$logmsg);
     fclose($loghandle);//关闭日志指针
     fclose($handle);//关闭指针
 }

 phptohtml("http://www.,dirname(_FILE_)."/html/index.html",dirname(_FILE_)."html/log.txt);
 echo"生成成功!!!";
 ?>
   



   
    调试的时候出现了以下情况:
Warning: Unknown: failed to open stream: Invalid argument in Unknown on line 0
Fatal error: Unknown: Failed opening required 'E:/Program Files /PHPnow/vhosts/127.0.0.5/鍒涘缓闈欐
搜索更多相关主题的帖子: 网页 php 静态 
2009-08-29 11:06
guang2356447
Rank: 2
等 级:论坛游民
帖 子:434
专家分:31
注 册:2007-7-10
收藏
得分:0 
if(is_dir(dir_array[$i]))

语法错误

 if(is_dir($dir_array[$i]))

phptohtml("http://www.,dirname(_FILE_)."/html/index.html",dirname(_FILE_)."html/log.txt);

看最后面少个“
phptohtml("http://www.,dirname(_FILE_)."/html/index.html",dirname(_FILE_)."html/log.txt");
2009-10-28 10:53
快速回复:求助,php生成静态网页问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018477 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved