codehaven - php snippets - coding help
Generic filters
Exact matches only
  • Text file Read – Create – Save write/delete fopen

    19th July 2013

    Php - Strings

    php codehaven
    Read text file

    Create a text file and add 122 to the file and save it

    Basic write to text file

    New file name

    Creates a new file with the milliseconds time (Filenumber-1232233223.txt)

    When run, this creates a text file (you may need permissions to write), the ‘a’ stands for append and will add a new line every time to the file.

    Write to specific line

    Delete Text file

    Delete all files in folder

    Rename file

    Copy file

    “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” (Write only. Opens and writes to the end of the file or creates a new file if it doesn’t exist)
    “a+” (Read/Write. 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)

    Was this code snippet helpful?