get_file_content

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
geblig
Forum Newbie
Posts: 2
Joined: Thu Dec 23, 2010 4:33 am

get_file_content

Post 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
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: get_file_content

Post 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
geblig
Forum Newbie
Posts: 2
Joined: Thu Dec 23, 2010 4:33 am

Re: get_file_content

Post 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
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: get_file_content

Post by Darhazer »

It responds with 3xx redirect header.
If you use curl, you can handle redirects as well.
Post Reply