1.fileopen Additional methods
<?php$fp=fopen (' File2.txt ', ' a '); $outputstring = ' to be appended '; Fwrite ($fp, $outputstring, strlen ($outputstring)); Fclose ($FP);? >
Several methods of 2.fopen reading
<?php//fgetc reads a string method $fp=fopen (' file.txt ', ' r '); Echo fgetc ($FP); fclose ($FP);/?><?php//fgets reads a row $fp= fopen (' file.txt ', ' r '); Echo fgets ($FP); fclose ($FP);? ><?php//fgetss reads a line to filter out HTML tags $fp=fopen (' file.txt ', ' r '); Echo fgets ($FP); fclose ($FP);? ><?php//fread reads the quantitative character $fp=fopen (' file.txt ', ' r '); Echo fread ($FP, 2); fclose ($FP);? ><?php// Fpassthru reads the remaining characters $fp=fopen (' file.txt ', ' R '), Fpassthru ($FP); fclose ($fp);//printing with EHCO can print out the number of characters remaining? The ><?php// file reads the entire document into the array and deposits it into an array line equal to one element $fp=fopen (' file.txt ', ' R '); $array _file=file (' file.txt ');p Rint_ R ($array _file); fclose ($FP);? ><?php//ReadFile read in all do not need to print $fp=fopen (' file.txt ', ' R '); ReadFile (' file.txt '); fclose ($FP);? ><?php//file_get_contents simple way to read file_get_contents (' file.txt ');? ><?//more flexible printing method with feof Do Loop $fp=fopen (' file.txt ', ' R '), while (!feof ($fp)) {echo fgetc ($FP);} Fclose ($FP);? >
PHP Learning records processing of files two