Popular Posts

Sunday, August 23, 2009

Write and read


/**
* @author At home processor
* @copyright 2009
*/

// String to write on file
$string="Hello!!!";
// Writing on file
$write_file=fopen("pippo.txt","w");
fwrite($write_file,$string);
fclose($write_file);
// Reading on file
// get contents of a file into a string
$filename = "pippo.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
?>

No comments: