this puzzled me for a few days£¬when I use the function 'fopen' with following :

<?php
$url = "http://www.php.net";
$handle = fopen ( $url, "rb");
$contents = "";
while( true ) {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
}
fclose ($handle);
var_dump( $contents );
?>

I got 2 warnings when I run it:

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/apache2/htdocs/heshun/kkk/zz.php on line 99

Warning: file_get_contents(http://www.php.net): failed to open stream: Invalid argument in /usr/local/apache2/htdocs/heshun/kkk/zz.php on line 99

to my surprise, when I log into my local net(BSD OS, PHP 4.3.10 ) and I run it by following :
shell# php -a zz.php
It can work well.why it happened this case? a bug? how can I resolve it ?

    I can be sure that the para 'allow_url_open' is 'on', you can see the following picture:
    someone think this is due to my entry to internet is ADSL perhaps. but the explaining is not satisfied with me.

      Why not try just a simple:

      $data = file_get_contents('http://www.php.net');

      if that doesn't work, try:

      $data = file_get_contents('http://216.109.118.67/'); // should have the contents of [url]www.yahoo.com[/url]
        Write a Reply...