title: File Reading
PHP prepared File Reading functions to ease user to only retrieve information outside PHP.
Before we read a file, we need to prepare the file in PHP using fopen function reading mode(“r”). The $fileHandler will be the file handler variable in the file reading operation.
"fileName.txt", "r"); $fileHandler = fopen(
After the desired file to be read has been prepared for reading, user can proceed to fread function to read contents of the file.
"fileName.txt")); $content = fread($fileHandler, filesize(
Content in the file “file.txt” will be stored in the variable $content.
This file reading function is rather easy. This function doesn’t need the file to be prepare by fopen().
"fileName.txt"); $content = file_get_contents(