sunucu kodlama problem

4 Cevap php
$fp = fopen("http://feeds.reuters.com/Reuters/PoliticsNews?format=xml","r")
    or die("Error reading RSS data.");

Yukarıdaki kodlama localhost düzgün çalışmak;;;

ancak sunucu ekran "okuma hatası RSS veri." in ...

i neden bilmiyorum ....

Kimse beni lütfen açıklayınız ...

i bekliyorum ...

teşekkürler

4 Cevap

Olası nedeni olabilir allow_url_fopen might be disabled (quoting):

This option enables the URL-aware fopen wrappers that enable accessing URL object like files.

Bunu etkin veya değil görmek için, phpinfo() fonksiyonunu kullanarak kontrol edebilirsiniz.


If it's not enabled, you'll have to use another solution to send the HTTP request that fetches that remote content.

Using curl might be a solution, for instance ; see curl_exec for a quick example, and curl_setopt for a list of all possible options.
Here's what a simple request would look like, though :

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://feeds.reuters.com/Reuters/PoliticsNews?format=xml");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$feed = curl_exec($ch);
curl_close($ch);

Bu size $feed içinde yem içeriğini alacak - ama manuel sayfasını kontrol curl_setopt: listesinde geçiyor kötü bir fikir olamaz o kadar çok seçenek vardır.


Still, as a precaution, before going this way, you might want to check if curl is enabled, is the output of phpinfo()...

allow_url_fopen sunucusunda etkin olduğundan emin sahipsiniz. Değilse, fopen çağrısı başarısız olur.

Onun sunucu yapılandırılmış olması çok muhtemeldir so that fopen() can not open a remote URL. Sen beslemeleri ayrıştırma için Simplepie denemek isteyebilirsiniz, bunun dışında ağrı alır.

"olası nedenler" ve gerçek bir sebep nasıl tek bir öneri çöp konuşuyor.

ini_set('display_errors',1);
error_reporting(E_ALL);

yanlış giden ne görmek için komut dosyası üstünde.