+ 3

PHP Reading Files

What's the difference between doing fopen('file.txt', 'r') and file('file.txt') (then using a foreach loop or something) when you're trying to read a file in php?

11th Aug 2019, 11:14 AM
Rachel
Rachel - avatar
2 Answers
+ 13
The difference is in speed and syntax. You can find the comparison of fopen, fgets, file_get_contents on the Internet. I remember that file_get_contents is the most convenient and the fastest way of reading files.
11th Aug 2019, 3:14 PM
Igor Makarsky
Igor Makarsky - avatar
- 2
r for reading file ,a for append and w Jifor writing but only file under pressure
21st Aug 2019, 5:01 PM
sanjeet kumar
sanjeet kumar - avatar