2011-12-13 55 views
0

我有这样的代码,并在本地主机上正常工作,但在服务器上给我的错误:流和file_put_content

警告:stream_get_contents()[function.stream-GET-内容]:流不支持查找在/ home /在线41上的pluspon/public_html/get.php

警告:stream_get_contents()[function.stream-get-contents]:无法在/ home/pluspon/public_html/get.php中找到位置0的流line 41

CODE:

$site = fopen('http://www.google.com', 'r'); 
$store = 'store.php'; 
$stream__ = stream_get_contents($site, -1, 0); 

file_put_contents($store, $stream__, LOCK_EX); 
fclose($site); 
$check = file_get_contents($store); 

# var_dump($check); print_r($check); var_export($check); 
# or simple... 

echo $check; 

这种错误意味着如何解决这个问题!

+0

在屏幕或apache错误日志上输出这些错误吗?在stream_get_contents($ site,-1)中删除0。在这种情况下没有必要。 – JM4 2011-12-13 20:38:39

回答

2

任何原因,你不能只是做:

file_put_contents($store, file_get_contents('http://google.com')); 

呢?由于您正在获取指定网址的全部内容,因此使用流机制没有任何意义 - 您不仅仅只获取一部分内容,还没有使用GET请求以外的其他任何内容,无需身份验证等。

+0

如何解决这个问题? – Andrew 2011-12-13 20:40:05