Utilizor
Contact Us

PHP File Handling

Reading and writing files.

PHP File Handling

File handling is an important part of any web application. You often need to open and process a file for different tasks.

PHP File Modes

  • r - Open a file for read only.
  • w - Open a file for write only. Erasess contents or creates new file.
  • a - Open a file for write only. Appends data or creates new file.
  • x - Creates a new file for write only. Returns FALSE and error if file already exists.

PHP readfile() Function

The readfile() function reads a file and writes it to the output buffer.