Read and Write file in php: in this post with a simple php code u will learn how to read content from and write into a file using php code i’m trying to explain and share codes with you in a simple way that be easy and understandable for beginers , in this sampe we will use 2 functiosn of php to do this file_get_contents — Reads entire file into a string and file_put_contents — Write a string to a file
enter code to Kroger Feedback survey and win $5000
1 2 3 4 5 6 7 8 9 10 |
<?php $file = 'ali.txt'; // Open the file to get existing content $current = file_get_contents($file); echo $current; // Append a new text to the file $current .= "this is new text \n"; // Write the contents back to the file file_put_contents($file, $current); ?> |