问题标题小小错误,应该是 "如何将动态页面写成一个.html静态页面?"

解决方案 »

  1.   

    我也想过这个问题。这样可以大大提高速度。你可以在数据库里面设一个字段。比如flag=0/1.  为1就是本 a=n已经生成了html文件。直接调用就行。如果不是,就用文件操作把test.php?a=n生成n.html页!!
      

  2.   

    我知道是用fwrite()
    <?
    $filename = "http://218.98.0.168/icon/body.php?listnow=ik";
    $fd = fopen( $filename, "r" );
    $contents = fread($fd, filesize($filename));
    fclose( $fd );
    echo $contents;$fp = fopen('test.html', 'w');
    fwrite($fp,$contents);
    fclose($fp);
    ?>为什么我这样写结果是什么也得不到?
      

  3.   

    你fread的东东完整吗?不是读本地的文件可能读出来吗?你echo出来的东东是以字符串形式存储的吗?
      

  4.   

    那应该怎么写?我这完全是从手册copy下来的,上面说fopen可以打开http://的您能帮我试一下吗
      

  5.   

    整个完整的流程:
    所有工作都由你的test.php负责.
    当调用test.php?a=02时.你用file_exists函数,判断是否存在02.html.
    1)存在: 可以将02.html的内容用fopen然后fread读入再显示,也可以用header重定向到02.html.(推荐用重定向)2)不存在: 把内容写入02.html.然后就和存在的时候一样.
      

  6.   

    2)不存在: 把内容写入02.html.然后就和存在的时候一样.我就想知道怎么写.
      

  7.   

    晕倒.
    你的test.php不是负责输出内容的吗? 把输出的内容写入文件不就可以了?
      

  8.   

    <?
    $filename = "http://218.98.0.168/icon/body.php?listnow=ik";
    $fd = fopen( $filename, "r" );
    $contents = fread($fd, filesize($filename));
    fclose( $fd );
    echo $contents;$fp = fopen('test.html', 'w');
    fwrite($fp,$contents);
    fclose($fp);
    ?>哪里不对了
      

  9.   

    filesize不能获取远程文件的大小.
    把filesize($filename)改成100000000.其它暂时没发现错误.
      

  10.   

    谢谢!此句正中要害
    我再想请问
    <?
    $filename = "body.php";
    //$fd = fopen("http://www.php.net/", "r");
    $fd = fopen( $filename, "r" );
    $contents = fread($fd, 100000000);
    fclose( $fd );
    echo $contents;这样得到的数据却是 body.php的源码
    如果$filename = "body.php?listnow=aa";
    这样根本找不到
    如何能不以http://引用地址却可以是以http方式取得php内容输出的?
      

  11.   

    好像是做不到的。你可以自己拼出URL地址,去读得HTML内容。并不难。