GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, January 2, 2011

FileSystem In PHP

To get all content from a file, and then give it to a variable, use:
$contents = file_get_contents("lola.txt");
echo $contents;

To insert a string to a file, use:
$text = "hello world\n This is lady gaga\n This is luna maya";
file_put_contents("lola.txt",$text);    // return char of text
                                        // inserted

To know file size, use:
echo filesize("lola.txt");
       
Share/Bookmark

No comments:

Post a Comment