php 5.3 - why does PHP fopen + fwrite double document? -


i running php version 5.3.4 apache/2.2.17 on windows 7 ultimate 32bit (iis disabled). been looking @ fopen modes , aware of mode what, can't wrap finger around why double posting txt file single fwrite. i've tried modes: w , c.

now don't care whether new data coming in being prepend or appended, long there in file without truncating existing data.

the real question is, why "a" mode instead of appending new data, writes (duplicates) new data file twice before closes.

in php code:

$fh = ""; if(!($fh = fopen("list.txt","x")) // if file exists, open writing (prepend)    $fh = fopen("list.txt","a"); // if not exist, open writing (append)  fwrite($fh,"somthing\r\n"); // write file (filehandle, "data") fclose($fh); // close file 

results:
somthing
somthing

solved: found culprit: nothing wrong coding. html validator extension used chromium under ubuntu 10.04. extension apparently causing similar instant page reload.

$fh = fopen("list.txt","a"); fwrite($fh,"somthing\n"); // write file (filehandle, "data") fclose($fh); // close file 

your logic not correct.

that's how done, hope works you


Comments