PHP read, delete, write to file instance tutorial
-------------------------------Delete Files
function Delfiletext ($filename) {
@unlink ($filename);
}
---------------------------------get the contents of the file
function Readfiletext ($filepath) {
$HTMLFP = @fopen ($filepath, "R");
while ($data = @fread ($HTMLFP, 1000))
{
$string. = $data;
}
@fclose ($HTMLFP);
return $string;
}
--------------------------------Write a file
function Writefiletext ($filepath, $string) {
Global $filechmod;
$string =stripslashes ($string);
$fp = @fopen ($filepath, "w");
@fputs ($fp, $string);
@fclose ($FP);
if (empty ($filechmod))
{
@chmod ($filepath, 0777);
}
}
//--------------------------------Write file
function writefiletext_n ($filepath, $string) {
global $ Filechmod;
$fp = @fopen ($filepath, "w");
@fputs ($fp, $string);
@fclose ($FP);
if (Empty ($filechmod))
{
@chmod ($filepath, 0777);
}