[PATCH] New function file_put()
| From: | Christian Schneider | Date: | Wed, 16 Oct 2002 00:26:19 +0000 |
| Subject: | [PATCH] New function file_put() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-89526@lists.php.net to get a copy of this message | ||
Hi Folks,
after seeing the new function file_get_contents() I figured a
corresponding file_put() function should be added too.
Prototype:
int file_put(string filename, mixed data [, string mode])
It takes a filename (URL wrappers supported), the data to be written and
a mode for the file. The data can be either a string or an array (which
is like using join("", $data) first and can be used to write data read
by the file() function). The mode can be "a" or "ab" to append to a file
and defaults to "wb". The function returns the number of bytes written
to the stream.
A test for the function has been included in
ext/standard/tests/file/002.phpt.
On a side note: I think the file_get_contents() function should be
renamed to file_get() as it is useful enough to deserve a shorter name.
Any comments on this function (and the implementation) are welcome.
- Chris