The following code shows an Example of Creating Files in Append Mode in PHP.
Both a and a+ file modes open a file in append mode. However, the append mode a opens the file in append-only mode. Whereas, the a+ mod opens the file in append and read mode. Therefore, it doesn’t delete the existing contents of a file. The file pointer is placed at the end of the file from where the writing starts.
<?php // Creating a file $text1=fopen("file1.txt", "a"); $text2=fopen("file2.txt", "a+"); $data1="\nThis file is appended using the 'a' mode!!!"; $data2="\nThis file is appended using the 'a+' mode!!!"; fwrite($text1, $data1); fwrite($text2, $data2); echo 'Contents of the first file...<br>'; fseek($text1, 0); $f1=fread($text1, filesize('file1.txt')); var_dump($f1); echo '<br>Contents of the second file...<br>'; fseek($text2, 0); $f2=fread($text2, filesize('file2.txt')); var_dump($f2); ?>
- Dot Net Framework
- Power Bi
- Scratch 3.0