note 62641 added to function.file-put-contents
| From: | sendoshin at awswan dot com | Date: | Mon, 06 Mar 2006 07:01:04 +0000 |
| Subject: | note 62641 added to function.file-put-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104882@lists.php.net to get a copy of this message | ||
To clear up what was said by pvenegas+php at gmail dot com on 11-Oct-2005 08:13, file_put_contents()
will replace the file by default. Here's the complete set of rules this function follows when
accessing a file:
1. Was FILE_USE_INCUDE_PATH passed in the call? If so, check the include path for an existing copy
of *filename*.
2. Does the file already exist? If not, first create it in the current working directory. Either
way, open the file.
3. Was LOCK_EX passed in the call? If so, lock the file.
4. Was the function called with FILE_APPEND? If not, clear the file's contents. Otherwise,
move to the end of the file.
5. Write *data* into the file.
6. Close the file and release any locks.
If you don't want to completely replace the contents of the file you're writing to, be
sure to use FILE_APPEND (same as fopen() with 'a') in the *flags*. If you don't,
whatever used to be there will be gone (fopen() with 'w').
Hope that helps someone (and that it makes sense ^^)!
- Sendoshin
----
Server IP: 216.194.113.175
Probable Submitter: 66.133.251.217
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php
Edit -- http://master.php.net/note/edit/62641
Del: integrated -- http://master.php.net/note/delete/62641/integrated
Del: useless -- http://master.php.net/note/delete/62641/useless
Del: bad code -- http://master.php.net/note/delete/62641/bad+code
Del: spam -- http://master.php.net/note/delete/62641/spam
Del: non-english -- http://master.php.net/note/delete/62641/non-english
Del: in docs -- http://master.php.net/note/delete/62641/in+docs
Del: other reasons-- http://master.php.net/note/delete/62641
Reject -- http://master.php.net/note/reject/62641
Search -- http://master.php.net/manage/user-notes.php