communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "file handling" - download "write to file"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

file handling - write to file was created/last modified on Sun 25 Apr 2004 9:21 PM

write to a file

<?
  
function file_write($filename, $filecontent)
{
      if(
$fp = @fopen($filename,"w "))
     {
          
$contents = fwrite($fp, $filecontent);
          
fclose($fp);
          return
true;
      }else{
          return
false;
      }
  }

// use like

  
file_write('path/to/file.txt','this is a test string');

  
?>  

learn more about some of the PHP functions used in this snippet: else, fclose, file, fopen, function, fwrite, return

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari