Ec (2); php read, delete, Write File instance tutorial --------------------------------- delete file functionDelFiletext ($ filename) {& nbsp; @ unlink ($ filename );} --------------------------------- obtain the file content functionReadFiletext ($ filepa script ec (2); script
Php example of reading, deleting, and writing files
// --------------------------------- Delete an object
Function DelFiletext ($ filename ){
@ Unlink ($ filename );
}
// ----------------------------------- Obtain the File Content
Function ReadFiletext ($ filepath ){
$ Htmlfp = @ fopen ($ filepath, "r ");
While ($ data = @ fread ($ HTML, 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 a file
Function WriteFiletext_n ($ filepath, $ string ){
Global $ filechmod;
$ Fp = @ fopen ($ filepath, "w ");
@ Fputs ($ fp, $ string );
@ Fclose ($ fp );
If (empty ($ filechmod ))
{
@ Chmod ($ filepath, 0777 );
}
}