Hello, can someone show me a short script of opening, writing, and closing to an external txt file? i know how to do this in perl, so im getting mixed up with php...
if (@$fp = fopen("set.".$setid.".dat","w")) { fwrite($fp,$numcards."\n"); for ($i =0; $i<$numcards; $i++) { fwrite($fp, serialize($set[$i])."\n"); //one card per row } fclose($fp); return true; } else { echo "set could not be saved"; return false; }
<?php $test = fopen (file.txt, "w"); fwrite ($test,"hi"); fclose ($test); ?>
whats wrong with that?
i used fpus instead of fwrite and it works... whats the diff???
fwrite is binary safe, fputs isn't.
My copy of the manual states: "fputs() is an alias to fwrite(), and is identical in every way". Binary-safeness is indicated when opening the file (as in Perl).