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 ?