1.

What is the difference between file_get_contents() and file_put_contents() in PHP?

Answer»

PHP has multiple FUNCTIONS to HANDLE files operations like read, write, create or delete a file or file contents.

1. file_put_contents():It is used to create a new file.

Syntax :

file_put_contents(file_name, contentstring, flag)

If file_name doesn't exist, the file is created with the contentstring content. ELSE, the existing file is override, unless the FILE_APPEND flag is set.

2. file_get_contents(): It is used to read the contents of a text file.

file_get_contents($filename);



Discussion

No Comment Found