I have a text file, and want to insert line "<?php ... ?>" by PHP to the top of this file, I tried:
but this will replace the character in text.txt with new line added, I need insert this line instead of replacement.
how can I do that?
Code:
$file = "test.txt";
$fp = fopen($file,'r+');
$newline = "<?php echo "$abc"; ?>";
fwrite($fp,$newline);
fclose($fp);
but this will replace the character in text.txt with new line added, I need insert this line instead of replacement.
how can I do that?