Apending in to a file in php
How to append in to file using php?
Explanation
It is much similar to file writing. The only difference is that we have to open the file in append mode ('a') instead of write mode ('w').
Step 1:Writing
E.g: We have a file as
test2.txt with write permission
The below code will explain you, how we do it
<?php
$file = "test2.txt"; // Here we define the file path
$open = fopen($file, "a"); // Here we open the file in append mode using the php method fopen()
fwrite($open,"Hai this is test message"); // Here we append in to the file using the method fwrite('instance','message') passing fopen instance and the string as arguments
?>
The Result : view the file
test2.txt