Re: fopen does not open URL-files
| From: | Eric Bolikowski | Date: | Thu, 18 Dec 2003 18:33:55 +0000 |
| Subject: | Re: fopen does not open URL-files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172964@lists.php.net to get a copy of this message | ||
"Taras Panchenko" <pantaras@unicyb.kiev.ua> wrote in message
news:20031218100917.22872.qmail@pb1.pair.com...
> I have 2 questions:
> 1) why gethostbyname() does not resolve my host name into IP?
> 2) why fopen() (and file()) does not open an external (URL) file via http?
> Please, see my example below:
> ------------------
>
http://www.management.kiev.ua/try-test/fopen-test-http.php
-----------------
> --
> <?
> echo gethostbyname("www.management.kiev.ua");
>
> $h=fopen("http://www.management.kiev.ua/MO/main.php",
> "r");
> echo fread($h,200);
> ?>
> --------------------- browser (interpreted) result -----------------------
> www.management.kiev.ua<br />
> <b>Warning</b>: fopen() [<a
>
> href='http://www.php.net/function.fopen'>function.fopen</a>]:
> php_network_getaddresses: getaddrinfo failed: No address associated with
> hostname in <b>/home/manageme/public_html/try-test/fopen-test-http.php</b>
> on line <b>4</b><br />
> <br />
> <b>Warning</b>: fopen(http://www.management.kiev.ua/MO/main.php) [<a
>
> href='http://www.php.net/function.fopen'>function.fopen</a>]:
> failed to
> create stream: Permission denied in
> <b>/home/manageme/public_html/try-test/fopen-test-http.php</b> on line
> <b>4</b><br />
> <br />
> <b>Warning</b>: fread(): supplied argument is not a valid stream resource
> in <b>/home/manageme/public_html/try-test/fopen-test-http.php</b> on line
> <b>5</b><br />
> -------------------- or as plain text ----------------------
> www.management.kiev.ua
> Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo
> failed: No address associated with hostname in
> /home/manageme/public_html/try-test/fopen-test-http.php on line 4
>
> Warning: fopen(http://www.management.kiev.ua/MO/main.php)
[function.fopen]:
> failed to create stream: Permission denied in
> /home/manageme/public_html/try-test/fopen-test-http.php on line 4
>
> Warning: fread(): supplied argument is not a valid stream resource in
> /home/manageme/public_html/try-test/fopen-test-http.php on line 5
> ------------------------------------
>
> Thanks a lot for help in advance,
> Taras V. Panchenko.
Try this rather(maybe it works):
<?php
$fp=fopen("http://www.management.kiev.ua/MO/main.php/",
"r");
echo fread($fp,200);
?>