PHP File Handling is very impotent for serious programmers, we often use File Handing methods in web development, In this post i will cover file – Create, Open, Read, Write, Append, Close, and Delete Methods.
Create a File
Open a File
Read a File
Write to a File
Append to a File
Delete a File
Close a File
File Handling Modes list
|r||Read only. Starts at the beginning of the file|
|r+||Read/Write. Starts at the beginning of the file|
|w||Write only. Opens and clears the contents of file; or creates a new file if it doesn’t exist|
|w+||Read/Write. Opens and clears the contents of file; or creates a new file if it doesn’t exist|
|a||Append. Opens and writes to the end of the file or creates a new file if it doesn’t exist|
|a+||Read/Append. Preserves file content by writing to the end of the file|
|x||Write only. Creates a new file. Returns FALSE and an error if file already exists|
|x+||Read/Write. Creates a new file. Returns FALSE and an error if file already exists|
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.