07-21-2008, 09:08 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
fopen
Hey!
I'm having some trouble with a function:
PHP Code:
/**
* Function file_put_contents
* Params $szFilename, $szInject
*
* Writes the text into the logfile. New text is always added in the beginning of logfile so that newest is always on top
* Returns true or false
**/
function file_put_contents($szFilename, $szInject) {
// Open the file
$szContent = fopen($szFilename, 'w+');
// Write the text into it
$put = fwrite($szContent, $szInject);
if($put) {
// If success, return true
return true;
}
// If failure, return false
return false;
}
Problem: Well it seems to overwrite the content of the file, so everytime the function is used, the file is replaced with a new content, and not ADDING the content.
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!
__________________
|
|
|
|