PHP4 User Manual: function-file

Source: Internet
Author: User
%% Width100 % (PHP3, PHP44.0.0) file -- read the entire file to the array description arrayfile (stringfilename [, intuse_include_path]). In addition to file (), The Returned values are arrays () same. Each document corresponding to each element in the array

TABLE border = 0 cellPadding = 0 cellSpacing = 0 height = "100%" width = "100%">

(PHP 3, PHP 4> = 4.0.0)

File -- read the entire file to the array

Description

Array file (string filename [, int use_include_path])

In addition to the array returned by file (), the other values are the same as those returned by readfile. Each element of the array corresponds to each row of the file, with a line break.

Note: Each row in the result array contains the end of the row. if you do not want the end of the row, you can use the trim () function to remove it.

If you want to search for files in the include path, you can use the optional second parameter and set it to "1 ".

// Obtain an array of web pages and print it
$ Fcontents = file ('http: // www.php.net /');
While (list ($ line_num, $ line) = each ($ fcontents )){
Echo"Line $ line_num:; ", Htmlspecialchars ($ line ),"
\ N ";
}

// Obtain a webpage to the string
$ Fcontents = join (', file ('http: // www.php.net /'));
?>

Warning
This function cannot be used in binary format!

Tip: If the "fopen wrappers" configuration has been enabled, you can use URL as the file name in this function.

See readfile (), fopen (), fsockopen (), and popen ().

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.