PHP如何实现捕获网页输出内容 如题。ob_get_contents()没有ob_start()好像不行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ob_get_contents()是取缓存中的数据 没有ob_start() 输出的数据不会缓存起来 <?phpecho $htm = file_get_contents("http://www.baidu.com");echo "--------------<br />";echo substr($htm,strpos($htm,"<body"),strpos($htm,"</body>"),strpos($htm,"</body>")-strpos($htm,"<body"));?> 上面的多了个参数<?phpecho $htm = file_get_contents("http://www.baidu.com");echo "--------------<br />";echo substr($htm,strpos($htm,"<body"),strpos($htm,"</body>")-strpos($htm,"<body"));?> 先谢谢楼上的,用file_get_contents可以获取输出,但是我的目的是获取当前脚本的输出内容,用file_get_contents就不行了,会死循环。test.php$htm = file_get_contents("http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']); ob_start();echo '...';echo ' do something ';$str = ob_get_contents();ob_end_flush();echo $str; fopen ,curl,file_get_contents都可以 不要ob_start(); 因为ob_strar()要改写原程序了。其实我的意思是写一个程序,这个程序可以很方便地捕获到某个页面的最终浏览器输出,这个程序通用化。当然不能每个页面都ob_strat(),末尾又ob_end_flush(); 再取他的缓存输出内容。 顶一下,望高手献招。exec()? echo exec('php d:/web/t1.php'); C:\Program Files\PHP 这个PHP的安装路径要在你的系统环境变量里面. smarty中多个模板引用变量无法访问 正则 Linux下有集成开发环境软件包吗? 高分求助 URLDecode解密字符串不换行的问题 php二维数组 火狐提示:内容编码错误,thinkPHP有麻烦 为什么有的分页代码能刷新,有的不能刷新? 怎样这他一样在每个图上面打上自己的标志 求救!还是session问题 帮我看一下,这句正则表达式是什么意思 php实现路径的问题
<?php
echo $htm = file_get_contents("http://www.baidu.com");
echo "--------------<br />";
echo substr($htm,strpos($htm,"<body"),strpos($htm,"</body>"),strpos($htm,"</body>")-strpos($htm,"<body"));
?>
echo $htm = file_get_contents("http://www.baidu.com");
echo "--------------<br />";
echo substr($htm,strpos($htm,"<body"),strpos($htm,"</body>")-strpos($htm,"<body"));
?>
test.php
$htm = file_get_contents("http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']);
echo ' do something ';$str = ob_get_contents();ob_end_flush();echo $str;