PHP File Handling

PHP File System allows us to create file, read file line by line, read file character by character, write file, append file, delete file and close file.

PHP Open File – fopen()

The PHP fopen() function is used to open a file.

Syntax

Example

PHP Close File – fclose()

The PHP fclose() function is used to close an open file pointer.

Syntax

Example

PHP Read File – fread()

The PHP fread() function is used to read the content of the file. It accepts two arguments: resource and file size.

Syntax

 

Example

Output

PHP Write File – fwrite()

The PHP fwrite() function is used to write content of the string into file.

Syntax

Example

Output

PHP Delete File – unlink()

The PHP unlink() function is used to delete file.

Syntax

Example

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *