home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / funcwritefile.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  536 b   |  30 lines

  1. To use this function call it with 
  2.  
  3. $rs = write_file("my_file", "foooo"); 
  4. $rs will return 1 on success and 0 on failure. 
  5.  
  6.  
  7.  
  8.  
  9.  
  10. <?PHP 
  11.  
  12. function write_file($filename, $contents) { 
  13.  
  14.  if ($fp = fopen($filename,  "w")) { 
  15.         fputs($fp, $contents, strlen($contents)); 
  16.         fclose($fp); 
  17.         return 1; 
  18.         } 
  19.  else { return 0; } 
  20.  
  21.         } 
  22. ?> 
  23.  
  24. -- Fredrik Steen - PHP/JAVA/LINUX 
  25.    nospam@stone.nu 
  26.  
  27. Member of K.L.U.G (Karlstad Linux User group). 
  28. http://www.klug.org 
  29. http://www.stone.nu 
  30.