function to write a string to a file

write to file” makes use of the built-in PHP functions file_write( ), fopen( ), fwrite( ) and fclose( ).

01 <? 
02 function file_write($filename, $filecontent)
03 { 
04     if($fp = @fopen($filename,"w "))
05     { 
06         $contents = fwrite($fp, $filecontent, 80000); 
07         fclose($fp); 
08         return true; 
09     }else{ 
10         return false; 
11     } 
12 } 
13 ?>