用OB函数生成静态HTML页面时,怎么能得到类似news.php?id=1的ob_get_contents()内容。请高手指导!

解决方案 »

  1.   

    ???
    ========================
    ob_start();
    require_once('news.php?id=1');
    $page = ob_get_contents();
    ob_end_clean();
    ..
    ..
    ..
    echo $page
      

  2.   

    <? $id=$_POST['id'];
    $htmlname=date("Ymd").$id.".html";
    $htmlpath="html/".$htmlname;
    function createhtml($id,$objectPage)
    {if (is_file ($objectPage)){
      @unlink ($objectPage);
     }
        ob_start(); 
    $content=file_get_contents("http://127.0.0.1/yinshua/news.php?fid=$id"); 
    echo "$content";
    $cons=ob_get_contents();
    ob_end_clean();  
    $fp=fopen($objectPage,"wb") or die("静态生成时打开文件".$objectPage."时出错");
    fwrite($fp,$cons); 
    fclose($fp);
    return true;
    }




    if(isset($_POST['Submit']))
    {
    createhtml($id,$htmlpath);
    }






    ?>
    <form name="form2" method="post" action="<?=$PHP_SELF?>">
    <table>
    <tr bgcolor="#FFFFFF"> 
          <td width="49" > <?php 
      include_once('include/db_class.php');
    $result1=$db->query("select * from article order by id  limit 0,12");
     while($row1=$db->getarray($result1)){?>
        <TR>
                                <TD class=cl align=right>
    <input type="radio" name="id" value="<?=$row1[id]?>">
    <?=$row1[title]?></TD></TR>
      <TR><TD height="5"></TD></TR> 
     <?php } ?></td></tr></table>
      <input type="submit" name="Submit" value="加载页面">
      </form>
      

  3.   

    $content=file_get_contents("http://127.0.0.1/yinshua/news.php?fid=$id");
    ============================================================
    http://127.0.0.1/yinshua/news.php?fid=$id --> 改成相对地址.
      

  4.   

    o,试试fsockopen打开,肯定不是ob函数的问题。