File Handling is the most important part of web application. For different task you need to open and process a file.
Manipulating Files :
Creating, Reading, Uploading, and Editing files has several functions for PHP.
If you do something wrong, it can damage a lot so be careful while manipulating files. Filling a hard-drive with garbage data, editing wrong files and by mistake deleting a content of a file : these are the common errors.
This function reads & writes it to output buffer. If you want to open file and read its all contents then readfile() is much useful.
- At first, i have created a file named “example.txt” which contains the following information :-
This is an example.
#teamcodeprojects – projects, tutorial and more
NOW PHP CODE READs THE FILE AND DISPLAYS THE OUTPUT :
<!DOCTYPE html> <html> <body> <?php echo readfile("example.txt"); ?> </body> </html>