The fwrite() is used to write the contents to text file.
Syntax:
fwrite($fp,’content’);
// content will be written $fp pointer and it will be written in data.txt.
Program:
<?php $fp = fopen('data.txt', 'w'); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); // the content of 'data.txt' is now 123 and not 23! ?>
Output:
data.txt file:
// it will be written in the data.txt, which will be in the same location of php source file.
Thanks for reading this post……….!!!