2011-02-17 42 views
1

问题:我们有工作不正常大的代码库。我们通过排除法想通下面几行导致该问题。PHP:两台机器,不同的结果用一个简单的PHP脚本

我们有两台机器小相同的脚本(快捷键已被修改)。

$url = "http://images.shrinktheweb.com/xino.php?stwsize=xlg&stwaccesskeyid=82322b94fs1c912&stwu=bfbf5&stwinside=1&stwurl=http%3A%2F%2Fwww.digitalartistshandbook.org%2Fnode%2F35";  
$lines = file($url); 
print implode("", $lines); 

机1:

  • 这个脚本工作正常,并打印出预期的响应。

机器2(问题):

  • 这个脚本不工作,不打印任何内容到终端。它在php.log或终端中没有错误。现在

,另一个脚本:

$url = "http://images.shrinktheweb.com/xino.php?stwsize=xlg&stwaccesskeyid=82322b94fs1c912&stwu=bfbf5&stwinside=1&stwurl="; 
$lines = file($url); 
print implode("", $lines); 

我们有过的URL与stwurl组工作的奇怪的时刻,但并不可靠 我们回去,并试图其中一些已经成功地检索缩略图和couldn”让他们工作。

错误和的fopen设置:

 
;;;;;;;;;;;;;;;;;; 
; Fopen wrappers ; 
;;;;;;;;;;;;;;;;;; 

; Whether to allow the treatment of URLs (like http:// or ftp://) as files. 
allow_url_fopen = On 

; Whether to allow include/require to open URLs (like http:// or ftp://) as files. 
allow_url_include = Off

这是一个两台机器。错误配置:

error_reporting = E_ALL 

和两个成功登录(使用卷曲或wget的),以/tmp/php.log

+3

基本调试:什么是这个输出代码 - 'echo'here 1'; $ lines = file($ url);回声'这里2'; implode(“”,$ lines);回声“在这里3”;' – 2011-02-17 12:38:13

+0

您好丹,所有的回声都成功地打印。所以,我假设文件()中$行是空的。感谢您的回复 - 任何其他建议? – justme 2011-02-17 13:01:09

回答

0

尝试从两台机器的命令行访问该URL。这可能是网络(或防火墙)问题。

0

是任何这些参数一个使用专用的?尝试在第二台机器上加载相同的URL,然后在第一台机器上加载。

哦,还有,即使只是为了简单起见,你可以重构

$lines = file($url); 
implode('',$lines); 

东西用的file_get_contents($网址),以进一步简化此事