<?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);
}
?>
$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。
<?
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.在自己机器上写好程序,用离线浏览器抓取.
PHP——
1、可以使用输出控制函数ob_xxxx
2、也可以简单的
$str = file_get_contents(url);
ob_start();//打开缓冲区
?>
php页面的全部输出
<?
$content = ob_get_contents();//取得php页面输出的全部内容
$fp = fopen(“output.html”, “w”); //创建一个文件,并打开,准备写入
fwrite($fp, $content); //把php页面的内容全部写入output.html,然后……
fclose($fp);
?>
Response.Buffer = True;