Write entire file

From Rosetta Code
Revision as of 20:45, 22 October 2015 by rosettacode>Binki (Create inverse of Read entire file. Seed with php and python.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Write entire file
You are encouraged to solve this task according to the task description, using any language you may know.

(Over)write a file so that it contains a string.

The reverse of Read entire file—for when you want to update or create a file which you would read in its entirety all at once.

PHP

<lang php>file_put_contents($filename, $data)</lang>

Python

<lang python> with open(filename, 'w') as f:

   f.write(data)

</lang>