Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to open, read and close a file in PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 84
    Comment on it

    Open a file in PHP:

    To open a file in PHP fopen() funtion is used. Syntax:

    fopen(filename, mode)
    

    filename is the name of the file you want open. mode can be r,w,a,x,r+,w+,a+,x+.

    Read a file in PHP:

    To read an open file fread() function is used. This function have two parameters:

    • first parameter contains the name of the file to read.
    • second parameter specify the number of bytes to read.

    Syntax:

    fread($myfile,number_of_bytes);

    Close a file in PHP:

    To close an open file in PHP fclose() function is used. It only requires a name of the file to close.

    Syntax:

    fclose($myfile);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: