PHP Read File
Case One
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
This case does not support remote
$fso = fopen ($file, ' R ');
echo $data = Fread ($fso, FileSize ($file));
Fclose ($FSO);
?>
fopen () binds the name resource specified by file to a stream.
FileSize returns the number of bytes in the file size if an error returns FALSE.
Note: Because PHP's integer type is signed, and most platforms use 32-bit integers, the filesize () function may return unintended results when it encounters a file larger than 2GB. For files between 2GB and 4GB, you can usually use sprintf ("%u", Filesi Ze ($file)) to overcome this problem.
Fread () reads up to length bytes from a file pointer handle. The function will stop reading a file when it is available, or (for a network stream) when it has been read by the length of bytes, or when it reaches EOF, depending on what kind of situation is encountered first.
Description: Low version usage! Recommended PHP5 with File_get_contents
Case Two
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
Support remote
$file = ' http://www.jb51.net ';//
echo $data = Implode (', File ($file));
?>
FILE--Reads the entire document into an array
Description
Read binary files
Case Three
Copy CodeThe code is as follows:
$file = ' http://www.jb51.net ';
Echo file_get_contents ($file);
?>
File_get_contents--Reads the entire file into a string
Description
String file_get_contents (string filename [, int use_include_path [, resource context]])
As with file (), the file is returned as a string except for file_get_contents ().
The file_get_contents () function is the preferred method for reading the contents of a file into a string. If operating system support also uses memory-mapping techniques to enhance performance.
http://www.bkjia.com/PHPjc/326101.html www.bkjia.com true http://www.bkjia.com/PHPjc/326101.html techarticle PHP Read file case a copy code code as follows: PHP $file = ' jb51.net.php ';//This case does not support remote $FSO = fopen ($file, ' R '); Echo $data = Fread ($fso, file Size ($file)); FCL ...