Hey all, focusing on developing a template system for my very own open source. I wish to allow it to be completely edittable just like a wordpress theme. I'm wondering what the best technique is when it comes to fwriting/fileputcontents and overall organization of methods it's done?
I am talking about, I am basically going for a file say footer.php, fopen'ing it inside a+ mode and putting all it's content right into a textarea. The consumer then edits it, after which I'd obvious the files contents, and write the textareas content towards the same file. Then close that file.
Possibly there's an easy method to do it, and that is my question :P.
It does not matter if you are using: fopen, fwrite &lifier fclose rather than file_put_contents (observe that this really is PHP5 only -) )
Observe that this is just a shortcut, however i think it's easier to use since your code is going to be cleaner.
This content from the file in the event you get with file_get_contents, since the fread() only will get 8192 bytes and than you have to make use of a loop. (for additional informations go to the docu. )
But here my version:
- file_get_contents('foo.bar') // right into a textarea
- retrive the brand new version
- and write the brand new file with file_put_contents(), that old you will be changed.