大家好,我属于比较菜鸟级别的php编程,现在遇到一个问题,就是我的代码都没有问题,在putty调试下都能正常运行已经正常显示,可是在浏览器中就显示不出来。这类代码都有关screen scraping类的。比如,一段很简单的代码<?php$url="http://www.onion.com/";
$data=file_get_contents($url);
$start_index=stripos($data,"<h3>");
$end_index=stripos($data,"</h3>");$h1=substr($data,$start_index,($end_index-$start_index)+5);echo "$h1\n";
echo "data";?>data是可以在浏览器中运行出来的,但是抓取的$h1就不能显示了。
用putty调试,就可以正常输出。我搜了很多,实在不知道什么问题,比较初级的编程,谢谢大家了!!
$data=file_get_contents($url);
$start_index=stripos($data,"<h3>");
$end_index=stripos($data,"</h3>");$h1=substr($data,$start_index,($end_index-$start_index)+5);echo "$h1\n";
echo "data";?>data是可以在浏览器中运行出来的,但是抓取的$h1就不能显示了。
用putty调试,就可以正常输出。我搜了很多,实在不知道什么问题,比较初级的编程,谢谢大家了!!
<?php$url="http://www.onion.com/";
$data=file_get_contents($url);
$start_index=stripos($data,"<h3>");
$end_index=stripos($data,"</h3>");$h1=substr($data,$start_index,($end_index-$start_index)+5);echo "$h1\n";
echo "$data";?>echo "data";
应该为echo "$data";
echo "data";
这里的h1有必要带引号吗,另外echo "data";这个是啥意思?不是直接输出data这四个字母吗。
应该是echo $h1."\n";echo $data;吧!
问题在于在命令行下可以显示,浏览器中显示不了。我试了很多台机器也都更改了浏览器设置,还是不行~