![]() |
fopen
Hey!
I'm having some trouble with a function: PHP Code:
I want the marker at the beginning of the file when opened so the newest text is written in the beginning. I also want it to CREATE the file if the file does not exist. Thanks in advance! |
Without looking into fopen flags, here's what I would do off the top of my head:
PHP Code:
'w+' won't work, because as the manual says: Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. Your function will probably work just the way it is if you change w+ to r+, like so: PHP Code:
|
The first one without flags will probably be the best shot, why didn't I think of that...?
The one with r+ won't work, because r+ does not attempt to create it if it doesn't exist.. =// |
Right, I forgot that part. ;-)
You could always check file_exists first, PHP Code:
|
Are you working with PHP4 since you use a function called file_put_contents() cause in PHP5 theres one called that (=
|
I got it working:
PHP Code:
|
| All times are GMT. The time now is 11:46 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0