Neden bazen) (file_get_contents kullanarak içerik alamıyorum?

0 Cevap php

Kod basittir:

<?php
function getStringFromUrl($url){

    $fResource = fopen($url, 'r');
    do {
        $data = fread($fResource, 8192);

        if (strlen($data) == 0) {
            break;
            }   

            $contents .= $data;
    } while(true);

    fclose ($fResource);

    $contents = mb_convert_encoding($contents,'utf-8','gbk');
    return $contents;
}


echo getStringFromUrl(urlencode('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=text&ip=119.97.23.59'));

echo file_get_contents('http://blog.sina.com.cn/rss/1400122351.xml');

Bazen içerik olsun, bazen olamaz. Nedenini bilemiyorum.

(EDIT: hata msg: [function.fopen]: failed to open stream ve [function.file-get-contents]: failed to open stream)

Of course the 2 URL above are available. I have also set the allow_url_fopen = On in php.ini.

0 Cevap