<?php 
$start="<html>\n<head>\n<title>First Page</title>\n<head>\n\n<body>\n";
$content="这是一个测试啦。\n";
$end="</body>\n</html>";
$myfile="first.htm";
if(!file_exists($myfile)){
$fp=fopen($myfile,"w+");
fputs($fp,$start.$content.$end);
}
?>

解决方案 »

  1.   

    很多种办法:
    1。
    <?
    system("php.exe>out.txt myfile.php",$var);//东西全在out.txt里面了
    ?>
    2.
    <?
    $str=system("php.exe myfile.php",$var);//东西全在$str里面了,如果要传回数组用exec
    ?>
    3。交互操作
    $descriptorspec = array(
       0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
       1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
       2 => array("file", "/tmp/error-output.txt", "a"), // stderr is a file to write to
    );
    $process = proc_open("php", $descriptorspec, $pipes);
    if (is_resource($process)) {
        // $pipes now looks like this:
        // 0 => writeable handle connected to child stdin
        // 1 => readable handle connected to child stdout
        // Any error output will be appended to /tmp/error-output.txt    fwrite($pipes[0], "<?php echo \"Hello World!\"; ?>");
        fclose($pipes[0]);    while(!feof($pipes[1])) {
            $str=fgets($pipes[1], 1024);
        }
        fclose($pipes[1]);
        // It is important that you close any pipes before calling
        // proc_close in order to avoid a deadlock
        $return_value = proc_close($process);    echo "command returned $return_value\n";
    }
    4.在自己机器上写好程序,用离线浏览器抓取.
      

  2.   

    通过发Socket请求可以得到其输出。
      

  3.   

    ASP——不知道
    PHP——
    1、可以使用输出控制函数ob_xxxx
    2、也可以简单的
    $str = file_get_contents(url);
      

  4.   

    <?php 
    ob_start();//打开缓冲区 
    ?> 
        php页面的全部输出 
    <? 
    $content = ob_get_contents();//取得php页面输出的全部内容 
    $fp = fopen(“output.html”, “w”); //创建一个文件,并打开,准备写入 
    fwrite($fp, $content); //把php页面的内容全部写入output.html,然后…… 
    fclose($fp); 
    ?>
      

  5.   

    ASP打开缓冲:
    Response.Buffer = True;
      

  6.   

    Response.Buffer不能读取,你可以使用其它的方法,比如使用模板,BigHan曾写个一个aspTemplate,使用上类似phplib,你留个Email我可以发给你。
      

  7.   

    ob_start();然后用ob_get_contents()读出 写到变量中 再写入静态文件就可以我今天刚做了一个