Interesting functions in php (1)

Couple of days ago I was just practicing some of the interesting  built in fuctions in php.Actually I was searching for those function, I didn’t use any where but could be used in necessary purpose in near future.Found two pairs of function those can be very handy time to time.

The first pair is :

1.file_get_contents()  ->read the contents of a file into a string,

2.file_put_contents ->writes a string into a file

3.touch() ->create a blank file

4.fopen() ->opens file/url,by specifieing the mode(I opend the file read/write mode as why ‘w’ was parameter)

5.fwrite()->writes into a file

My codes were as follows:

<?php
$data = file_get_contents("mushfiq.doc");//$data = file_get_contents("http://localhost/sb");
echo $data;
touch("m4.doc");//craeting a blank file (same format)
$file = fopen("m4.doc","w");
file_put_contents("$file","$data");//fwrite($file,$data);
?>

Interesting outfut comes when I changed the parameter of file_get_contents() to url .Just check it and have fun 🙂

TiTbIt: To know more about the functions just goole or search the php manual

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s