File System Processing _, file system processing _
Touch ("./aa.txt"); // create a file
Copy ("./aa.txt", "../aa.txt"); // copy the file
Unlink ("./aa.txt"); // delete an object
Deleted. No graph.
Echo file_get_contents ("http://www.baidu.com"); // read the file
File_put_contents ("asdf.txt", "hello"); // write content
Readfile ("./asdf.txt"); // read and Output
Var_dump (file ("asdf.txt"); // reads the file content and returns an array. Each row is an element.
Open a file
$ F = fopen ("./11.txt"," ");
Fwrite ($ f, "wwwww ");
Close file
Fclose ($ f );
Example
// Delete a folder
// Give me a folder and delete it.
ShanChu ("./qiyezhan ");
Function ShanChu ($ fname)
{
If (is_dir ($ fname ))
{
// Delete all the files before deletion
$ Dir = opendir ($ fname );
While ($ dname = readdir ($ dir ))
{
If ($ dname! = "." & $ Dname! = "...") Top priority, careful writing
{
$ Durl = $ fname. "/". $ dname;
If (is_file ($ durl ))
{
Unlink ($ durl );
}
Else
{
ShanChu ($ durl );
}
}
}
Closedir ($ dir );
// Delete the folder
Rmdir ($ fname );
}
Else
{
// Delete a file directly
Unlink ($ fname );
}
}