In PHP, I have no trouble getting text from a local file and assigning it to a variable with fopen and fread... but as soon as I try to use it on a remote URL it stops working, even though the PHP manual says fopen should work on URLs.
When I use this, on any valid URL, the result of echoing $filecontents at the end is that it's blank:
Somebody on another forum suggested trying fsockopen, but using that it still doesn't function. Again it doesn't read any data when I fsockopen... $ftest never takes on any value no matter what the URL when I use
Any ideas on how to read text from a URL?
When I use this, on any valid URL, the result of echoing $filecontents at the end is that it's blank:
PHP:
$fd = fopen($url, 'r');
$filecontents = fread ($fd, filesize($url));
fclose ($fd);
Somebody on another forum suggested trying fsockopen, but using that it still doesn't function. Again it doesn't read any data when I fsockopen... $ftest never takes on any value no matter what the URL when I use
PHP:
ftest = fsockopen ($url, 80, $errno, $errstr, 30);
Any ideas on how to read text from a URL?
Last edited: