我试了一下,是可以的,看看php.ini中的allow_url_fopen有没有打开;也有可能目标不允许你这样读取

解决方案 »

  1.   

    <?php
    $handle = fopen ("http://www.example.com/", "rb");
    $data = fread($handle, 8192);
    echo $data;
    fclose ($handle);
    ?> 
      

  2.   

    你并未输出$contents 的内容,何以见得读不到呢?
      

  3.   

    You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.这试我测试得到的结果,楼主得不到吗?
      

  4.   

    不一定的我就遇到过这样的问题可能跟你的PHP版本或操作系统有关的.
    有一次我遇到这样一个怪现象.fread读到字节时就不读了!
    后来才发现是我的怪胎PHP版本的问题!呵呵呵.