Example Analysis of PHP file reading method
This article describes the php file read method. Share to everyone for your reference. Specific as follows:
?
1 2 3 4 5 |
$file = fopen ("Test//file.txt", "R"); Open File echo fgetc ($file); Read a character in a file Fclose ($file); Close File ?> |
?
1 2 3 4 5 |
$file = fopen ("Test//file.txt", "R"); Open File Echo fgets ($file); Read a line in a file Fclose ($file); Close File ?> |
?
1 2 3 4 5 |
$file = fopen ("Test//file.txt", "R"); Echo fread ($file, 20); Read the first 20 characters in a file Fclose ($file); ?> |
?
1 2 3 4 5 6 7 |
$filename = "Test//file.txt"; $file = fopen ($filename, "R"); $filesize = FileSize ($filename); Get file length Echo fread ($file, $filesize); Get the full contents of a file Fclose ($file); ?> |
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1020288.html www.bkjia.com true http://www.bkjia.com/PHPjc/1020288.html techarticle Example Analysis of PHP file Read method This article describes the php file read method. Share to everyone for your reference. Specific as follows:? 1 2 3 4 5? php $file = fopen (Test//file.txt, R); /...