我在我的電腦上有這段代碼,它運行得非常好,但是當其他人試圖在不同的環境中運行它時,getimagesize()
由於某種原因每次都返回false(應該返回true)。任何想法爲什麼這段代碼將在不同的環境中完全不同?爲什麼getimagesize()返回false?
$i = 2;
while ($i != 0){
$theFile = "url/to/images/" . $image . $i . ".GIF";
//echo $theFile . "<br />";
if ($imageSize = @getimagesize($theFile)){
//echo "added...<br />";
$theRow .= "<a href='" . $theFile . "' rel='lightbox[" . $image . "]'></a>";
$i++;
}else{
$i = 0;
}
}
如果我取消了兩行那裏所有$theFile
的打印的畫面精美,而且都是有效的網址,但它只是一堆
thisimage2.GIF
thatimage2.GIF
anotherimage2.GIF
...
他們都最終與2.GIF但有很多應該有3,4,5,6到12.FIF,但它永遠不會增加$ i,因爲它從不返回真正的getimagesize()。同樣,當我取消註釋echo $theFile . "<br />";
時,它會將有效的URL打印到圖像上,以便其他人可以將其粘貼到瀏覽器地址欄中,然後查看圖像。
我正在運行php 5.4.17,完全相同的代碼對我來說工作正常。另一臺機器正在運行php 5.4.7,並且無法正常工作。我試圖查找getimagesize()的兩個版本之間的差異,但找不到任何東西。
編輯:當沒有它不工作它提供了以下警告在機器上和getimagesize「@」()運行:Warning: getimagesize(): Unable to find the wrapper 「https」 - did you forget to enable it when you configured PHP?
開始通過擺脫@的''和讀取可能錯誤消息? – deceze
你要更改$ image和$ theFile? – Fredd
我會這麼做,讓這個人再次運行它。 –