2013-07-21 64 views
0

http://www.example.com/pageView?test=111&test2=999 - >數據加載和工作..

189 <?php 
190 $handle = @fopen("http://www.example.com". htmlspecialchars($_GET["test"]) ."/".  htmlspecialchars($_GET["test2"]) .".txt", "r"); 
191 while (!feof($handle)) 
192 { 
193 $buffer = fgets($handle, 4096); 
194 
195 if (strlen(trim($buffer)) > 0){ 
196 
197 list($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)=explode(",",$buffer); 
198 
199 $items[] = array('col1' => $a,'col2' => $b,'col3' => $c,'col4' => $d,'col5' => $e,'col6' => $f,'col7' => $g,'col8' => $h,'col9' => $i,'col10' => $j); 

200 } 
201 } 
202 ?> 

http://www.example.com/pageView?test&test2= - >不加載..這是正常的,但這個錯誤是在網頁..

Warning: feof(): supplied argument is not a valid stream resource in /home/---/public_html/---/---.php on line 191 

Warning: fgets(): supplied argument is not a valid stream resource in /home/---/public_html/---/---.php on line 193 

如何顯示警告信而不是錯誤頁?

+0

[PHP - FEOF錯誤]的可能重複(http://stackoverflow.com/questions/2875971/php-feof-error) – RiaD

+0

從fopen中刪除錯誤抑制調用線索以瞭解發生了什麼 – Orangepill

回答

1

檢查返回值fopen。如果閱讀你會得到$處理等於假期間出現了錯誤,但你需要「流資源」傳遞給eof

if($handle === false) { 
    print 'Err found'; 
} 
else { 
    while(!eof($handle)) ... 
} 
+0

非常感謝! – Editor

+0

@ TheSaracoglu通過點擊「正確」(接受)標誌接受答案。 –