Page 1 of 1

get_file_content

Posted: Thu Dec 23, 2010 4:36 am
by geblig
Hi,

I'm new to PHP and i'm trying to use the function "get_file_content" without luck :(
I'm using it like:

Code: Select all

$file = file_get_contents('http://www.example.com/');
echo strlen($file);
I get a blank output page. and strlen is returning 0.

What can be the problem?

Thanks,
Itzik

Re: get_file_content

Posted: Thu Dec 23, 2010 6:06 am
by Darhazer
most likely http wrapper is not enabled. Set error reporting to E_ALL and you will see the error message
In that case you can use curl to download file or enable allow_url_fopen

Re: get_file_content

Posted: Fri Dec 24, 2010 5:00 pm
by geblig
hi,

i managed with the file_get_contents after playing with the ini file.
Now, there are sites which i can get the url source code and there are sites which returns nothing...

like:
http://nzbmatrix.com/nzb-download.php?id=794772&cat=6

for example.

why is that... ? 8O
how can i solve this?

Thanks,
Itzik

Re: get_file_content

Posted: Sat Dec 25, 2010 3:37 am
by Darhazer
It responds with 3xx redirect header.
If you use curl, you can handle redirects as well.