Using the while loop to read file content by character _ PHP Tutorial

Source: Internet
Author: User
Use the while loop to read the file content by character. 01? Php0203 uses the while loop to read the file content by character 04 feof () to detect whether the file pointer has reached the end of the file: 0506 $ filePathUsersCufficaDesktopaddicte 01
02

03
// Use the while loop to read file content by character
04
// Feof () is used to detect whether the file pointer has reached the end of the file.
05

06
$ FilePath = '/Users/Cuffica/Desktop/addicted. rtf ';
07
$ Fp = fopen ($ filePath, 'r ');
08
While (! Feof ($ fp) {// when the condition is 1 and always true, execute the command repeatedly to enter the endless loop.
09
Echo fgetc ($ fp); // note that the accepted parameter is a handle, not a file name.
10
}
11

12
Fclose ($ fp); // close the file after use
13

14
?>
Author: dark circles

Http://www.bkjia.com/PHPjc/478010.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478010.htmlTechArticle01? Php 02 03 // use the while loop to read file content by character 04 // feof () used to check whether the file pointer has reached the end of the file 05 06 $ filePath =/Users/Cuffica/Desktop/addicte...

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.