File System Processing _, file system processing _

Source: Internet
Author: User
Tags dname

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 );
}
}


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.