File Handling in PHP: Read/Write To And From Text File

As a simple data storage alternative to Database Management System (e.g. MySQL) in PHP we can use plain text file. For example, a plain text file to store page counter information. Below is an example on how to store a simple string (text) into a text (.txt) file: <?php $data = ‘some text’; $fp = fopen(‘counter.txt’, ‘w’); if($fp) { fwrite($fp, $data); fclose($fp); } ?> Assuming a file named counter.txt exists Continue reading File Handling in PHP: Read/Write To And From Text File