0

In php, why use file to read

In php, the most common ways to read a file are fread(), fgets(), and fgetc(), why did you choose to only mention file()?

27th Jan 2020, 6:39 PM
Russ Howard
4 ответов
+ 1
Actually, I read that before I made my post. I have actually only used fread, fgets, and fgetc and i have been a php programmer since 2003. I am just thinking your students should be taught the most commonly used aspects of the language first.
27th Jan 2020, 6:55 PM
Russ Howard
+ 1
There even more ways to read like file_get_contents. file is very good to iterate different rows as it stores the file in an array.
27th Jan 2020, 7:03 PM
Daniel Rodriguez
Daniel Rodriguez - avatar
0
//There are some differences between between them, I want you to read this in W3schools https://www.w3schools.com/php/php_file_open.asp
27th Jan 2020, 6:43 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
Daniel, fgets will get things line by line as well. But if file_get_contents reads it directly into an array, i should have used it before. lol.
27th Jan 2020, 8:56 PM
Russ Howard