Skip to content
April 21, 2008 / ranacse05

Awesome File Trick

I was just reading PHP and got a awesome function named file_get_contents() it returns the whole file as a string.But the special thing is it can read web sites too 🙂 .For example here is a code
$data = @file_get_contents(‘’);
echo $data;
$file = fopen(‘google.txt’,’w’);

First line will get the contents of
Then it’ll show the data
And then it’ll save into a file named google.txt.

U can use it when u need some data from another site and if that site dont use the rss .

Note : Special thanks to Hasin Bhai he told me about this function a few days ago but i just forgot 😦 .



Leave a Comment
  1. mahfuz / Apr 21 2008 2:50 pm

    thats cool .

  2. hasin / Apr 21 2008 3:10 pm

    similarly , use file_put_contents() to write data inside a file 😀

  3. ranacse05 / Apr 21 2008 6:15 pm

    @Hasin Bhia
    Thanks again for this new function. 😀

  4. saeed ahmed / Jul 22 2008 5:15 pm

    hmm good.

  5. hasan uğur / Apr 10 2009 9:42 am

    i am getting one line from another site. but some characters are bad-looking now. i searched fixing the problem but not found.

    someone said to change your code :

    echo mb_convert_encoding($data[394], ‘utf-8’);

    but i doesn’t work. why i solve the problem? thanks for your help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: