डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

PHP file handling

PHP can create, read, update and delete a file.

  • readfile(): Read a file
  • fopen($file_name, $mode): Open or create a file with specified mode
  • fwrite($file, $txt): Write on a file with provided text.
  • fclose($file): Close current opened file
  • fread($file, filesize($file)): Read a file with specified file size.
  • fgets($file): Read first line of a file.
  • feof($file): Check end of file.
  • fgetc($file): Read single character from a file.
  • file_exists($file): Check file exist or not
  • filesize($file): Return size of a file
  • move_uploaded_file(file, destination): Move uploaded file to specified new location.
  • unlink($file): Delete a file

File can be open in following mode

  • r: Open a file for read only.
  • w: Open a file for write only, in this mode file content erased if file exist and create a file if does not exist.
  • a: Open a file for write-only, but old data preserve, create a new file if the file does not exist.
  • r+: Open a file for read-write.
  • w+: Open a file for read-write, content erased if file exists,s and create a file if does not exist.
  • a+: Open a file for read-write, content preserved if file exists, and create a file if does not exist.
  • x: Create a new file for write-only, return an error if the file already exists.
  • x+: Create a new file for read-write, return an error if the file already exists.
© 2016 - 2023, All Rights are Reserved.