PHP4 User Manual: Function -> File

zhaozj2021-02-08  226

File

(PHP 3, PHP 4> = 4.0.0) FILE - Read the entire file to array

description

Array file (string filename [, int us_include_path])

In addition to file () returns an array, others are the same as readfile (). Each element of the array corresponds to each line of the file, and has a wrap.

Note: Each line in the result array contains a row, if you don't want to do the end, you can use the Trim () function to remove it.

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

// Get an array of a webpage and print it

$ FCONTENTS = file ('http://www.php.net/');

While (List ($ line_num, $ line) = Each ($ fcontents)) {

echo " line $ line_num: ;", HTMLSPECIALCHARS ($ LINE), "
/ n";

}

// Get a web page to the string

$ fcontents = JOIN ('', file ('http://www.php.net/');

?>

WARNING This function cannot be used for binary!

Tip: If the "Fopen Wrappers" configuration is already open, you can use the URL as a file name in this function.

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

转载请注明原文地址:https://www.9cbs.com/read-3439.html

New Post(0)