PHP folder Operations 2

Source: Internet
Author: User

mkdir ("Path file name");    Create Folder Imdir ("Path file name");    Delete folder (can only delete empty folders)rename("Path", "New Path");    Move folder (can modify name) file operation:Touch("path");    Create a file copy("File path", "New file path");    Copy file unlink("file path");        Delete file file_get_contents("File path");    Gets the file contents (local content, remote content can be obtained)file_put_contents("File path". " Content ");    Write content Raedfile ("filename");        Read the contents of the Ask and output
$f=fopen("./11.txt", "R");//open a file and return a file resourcefwrite($f, "Hello World");//Write ContentEcho fgetc($f);//Read the contents of a file, a character read by one characterEcho fgets($f);//read the contents of a file, one line at a timeEcho fread($f, 10);//Read file contents, read by lengthfclose($f);//Close File Resource

deleting files

functionShanchu ($fname){    //traverse the folder to find all files deleted    $dir=Opendir($fname);  while($n=Readdir($dir))    {        if($n! = "." &&$n!="..")        {            $zname=$fname." /".$n; if(Is_file($zname))            {                unlink($zname); }            Else{Shanchu ($zname); }        }    }    Closedir($dir); //Delete a folder    rmdir($fname);} Shanchu ("./0904");

PHP folder Operations 2

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.