papaface Posted June 3, 2007 Share Posted June 3, 2007 Hello, How would I go about adding a string on a new line at the end of a text file? Link to comment https://forums.phpfreaks.com/topic/54092-solved-add-something-to-a-text-file/ Share on other sites More sharing options...
bonaparte Posted June 3, 2007 Share Posted June 3, 2007 Hi, Open the file in append mode and fwrite. Here's the example. <?php $myString = "Some text"; $fh=fopen('test.txt',"a"); fwrite($fh,$myString); fclose($fh); ?> Make sure to set appropriate permissions to the file test.txt so that PHP can open it. Link to comment https://forums.phpfreaks.com/topic/54092-solved-add-something-to-a-text-file/#findComment-267408 Share on other sites More sharing options...
papaface Posted June 3, 2007 Author Share Posted June 3, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/54092-solved-add-something-to-a-text-file/#findComment-267417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.