PX : code

Function for writing by Fredrik Steen
Download this code


To use this function call it with

$rs = write_file("my_file", "foooo");
$rs will return 1 on success and 0 on failure.

<?PHP

function write_file($filename$contents) {

 if (
$fp fopen($filename"w")) {
        
fputs($fp$contentsstrlen($contents));
        
fclose($fp);
        return 
1;
        }
 else { return 
0; }

        }
?>

-- Fredrik Steen - PHP/JAVA/LINUX
   nospam@stone.nu

Member of K.L.U.G (Karlstad Linux User group).
http://www.klug.org
http://www.stone.nu


Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.