2011-11-25 62 views
-2

我使用file_get_content來訪問rss。使用file_get_contents

我嘗試使用:

​​3210

結果是

的內容和我嘗試用

echo file_get_content("http://hcm.24h.com.vn/ban-tre-cuoc-song/noi-doi-de-quyen-ru-chang-c64a418748.html"); 

結果是一個空白頁。爲什麼我無法得到它?這個頁面不允許file_get_contents函數?對不起,我英語不好,請允許我的問題。謝謝

+0

這可能是一個網絡問題,或託管站點阻止您的訪問(從您的網絡或ip) – ajreal

+0

這不是一個RSS源。 RSS源位於http://www.24h.com.vn/upload/rss/bantrecuocsong.rss。看看是否http://stackoverflow.com/questions/5975213/how-can-i-download-using-php-a-xml-file-redirected-in-some-weird-way/5975340#5975340解決您的問題。 – Gordon

回答

3

你錯過了一個s。它應該是使用file_get_contents代替file_get_content

echo file_get_contents("http://hcm.24h.com.vn/ban-tre-cuoc-song/noi-doi-de-quyen-ru-chang-c64a418748.html"); 
+0

不錯的漁獲Jan :) –

+0

這仍然是空白頁。演示:http://kiengiangit.com/@forum/functions/tinhyeu-24h.php – vinanghinguyen

+0

嘗試改變你鏈接到http://www.google.com/''看你的腳本是否有效 – xDragonZ

1

首先它是的file_get_contents,不file_get_content。其次它不會與http鏈接一起工作。

http://vnexpress.net/gl/xa-hoi/2011/11/mot-so-bo-truong-the-hien-su-ne-tranh-trach-nhiem/

應該像

/家庭/ 48564568 /的public_html/GL/XA愷/ 2011/11/MOT-SO-博張庭-the- HIEN-SU-NE-tranh - 崔西 - nhiem/

根據您的服務器。

要找到鏈接應該是什麼,儘量包括像這樣

包括(somethingrandom.php)一個不存在的文件;

,您將收到一條錯誤通知,/the/path/you/need/somethingrandom.php不存在。

+0

請描述爲什麼file_get_contents不會與http鏈接工作 –

+0

這是一項安全措施。如果任何人都可以包含一個遠程php文件,可以將它包含在他們的網站上,並讓你的服務器執行PHP代碼。你可以通過在php.ini中設置allow_url_include爲ON來解決這個安全問題,但是我不會推薦它,因爲之前解決的安全漏洞。 – 2012-07-28 09:26:58

+0

+1爲您的描述 –