Re: file_put_contents() / file_add_contents() ?

From: Date: Fri, 21 Feb 2003 01:04:27 +0000
Subject: Re: file_put_contents() / file_add_contents() ?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-94411@lists.php.net to get a copy of this message
On Thu, 20 Feb 2003, Sara Golemon wrote: >I recall a discussion sometime back about making file_put_contents() (create >a file and write the provided contents to it in one command) and >file_add_contents() (like put but append rather than overwrite) to >complement file_get_contents() but looking in HEAD I don't see either put or >add. It sure would be nice to have..but why not just one function: bool file_write_content(string filename, string data [, bool append [, bool use_include_path]]); Then you could do something like this: <?php file_write_content('foobar.txt', 'foo!', file_exists('foobar.txt')); ?> Short and simple. With separate functions: <?php file_exists('foobar.txt') ? file_append_content('foobar.txt', 'foo!') : file_put_content('foobar.txt', 'foo!'); ?> btw. Why is that file_get_contents() named like that? Wouldn't it better be 'file_read_content()'? --Jani

« previous php.dev (#94411) next »