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