PHP AdvancedLesson 33Free preview
PHP File Open/Read
This lesson is part of PHP · All levels
Summary
Once the file is opened, PHP provides several ways to read it, from reading the entire content at once to per line. This lesson discusses fopen(), fread(), fgets(), file(), and file_get_contents(). You also learned the importance of closing a file after use.
Key points
- Read the entire file into a single string
- Fread() read a certain number of bytes from an open file
- Returns the contents of the file as array per row
- Always close the file with fclose() after use
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.