2011-02-17 39 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($網址),以進一步簡化此事