In this tutorials I will show you How to use file functions in php, how to read the file and write the file using php functions.
First make test.txt file and put some dummy content in that file.
Note: Make test.txt file group permission to 777 or writeable and readable.
$fp = fopen("test.txt","w");
$data = fgets($fp);
fwrite($fp, 'this is test text');
Using following function You are able to check the file size.
$fp = fopen('test.txt', 'r');
echo $data = fread($fp, filesize('test.txt'));
How to use file functions in php