PHP Language Open File View file

Source: Internet
Author: User
Tags php language

<?php
First, the "fopen" function is used to open the file, and the return value is the resource type.
$file _handle = fopen ("/data/webroot/resource/php/f.txt", "R");
if ($file _handle) {
It then uses a while loop (described in detail in the loop structure in the following language structure statement) to read the file line by row, and then output the text for each line
while (!feof ($file _handle)) {//Determines whether to the last row
$line = fgets ($file _handle); Reading a line of text
Echo $line; Output a line of text
echo "<br/>"; Line break
}
}
Fclose ($file _handle);//Close file

?>

PHP Language Open File View file

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.