How to read write text-files in PHP
How to read / write /copy file content in PHP PHP provided several predefined functions to read or write data from files. It is very common for developers to copy data from one source to another. File functions in PHP make things easier. In this article, we will use different types of file function to read data from files. Table of Contents Reading text Files Writing text Files Copy text Files To read a text from a file, we use the following methods in PHP fopen() feof() fread() fgets() fclose() fopen : function returns a file handle(file pointer) fread : reads specified no. of bytes fgets : reads line of text every time. feof : checks for end of file. Returns boolean value. fclose : closes an opened file. File must be closed when it is opened. menu Reading text Files fopen Example : index.php <?php $file_handle = fopen ( " about.txt" , "r" ); print $file_handle ; fclose ( $file_handle ); ?> o/p: Resource id #2