PHP Learning records processing of files two

Source: Internet
Author: User
Tags fread readfile

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.