When we develop a web application using PHP, quite often we need to work with external files, like reading data from a file or maybe writing user data into file etc. So it's important to know how files are handled while working on any web application.
File handling starts with creating a file, reading its content, writing into a file to appending data into an existing file and finally closing the file. Php provides pre-defined functions for all these operations, so let's start by knowing these functions.
fopen()
fopen()
fread()
fwrite()
fwrite()
fclose()
unlink()
You must be wondering that why we have specified same functions for multiple file operations, well, that is because just by changing one or more arguments, same function can be used to perform multiple operations on file.
We will learn how to use these functions along with code examples in the next tutorials.
Following are some of the practical use cases where we need files in our web applications.
The above usecases are just to show that very oftenly file handling is required.