Introduction to the use of unlink of mkdir of rmdir of and other methods in php

  • 2020-05-27 04:34:19
  • OfStack

The unlink() function deletes files, the mkdir() function creates directories, and the rmdir() function deletes directories
 
<html> 
<head> 
<title>unlink() Function usage instance </title> 
</head> 
<body> 
<? 
// use unlink Function deletes files  
$filename="data.txt"; // Define variables  
unlink($filename); // with unlink Function deletes files , Here, filename Should be relative address, that is, put the current page directory under data.txt Deleted. Return if successful  TRUE , failure returns  FALSE .  
// It was just used on the server today unlink When the function, with the relative address on the error, can not find the file, then change to the absolute address, deleted! This machine is window , the server is lunix . Is temporarily window I'm going to use the relative address, lunix Use the absolute address below! We used to see, is it so, to help confirm again!  
</body> 
</html> 
<html> 
<head> 
<title>mkdir() Function usage instance </title> 
</head> 
<body> 
<? 
// use mkdir Function create directory  
$dirname="mydir"; // Define variables  
mkdir($dirname,0700); // with mkdir To create a directory, the directory here is also relative to the directory that you create on this page 1 Called" mydir "Directory! Return if successful  TRUE , failure returns  FALSE .  
// Today just   Use on the server unlink When the function, with the relative address on the error, can not find the file, then change to the absolute address, deleted! This machine is window , the server is lunix . A tentative   is window I'm going to use the relative address, lunix Use the absolute address below! We used to see, is it so, to help confirm again!  
?> 
</body> 
</html> 
<html> 
<head> 
<title>rmdir() Function usage instance </title> 
</head> 
<body> 
<? 
// use rmdir Function delete directory  
$dirname="mydir"; // Define variables  
rmdir($dirname); // with rmdir To delete the directory, the directory here is also relative to the directory of this page 1 Called" mydir "Directory deleted! Return if successful  TRUE , failure returns  FALSE .  
// Today just   Use on the server unlink When the function, with the relative address on the error, can not find the file, then change to the absolute address, deleted! This machine is window , the server is lunix . A tentative   is window I'm going to use the relative address, lunix Use the absolute address below! We used to see, is it so, to help confirm again!  
?> 
</body> 
</html> 

Oh, simple application! The system always upload pictures, documents and so on, background management is to delete records, and not delete the actual uploaded file. Now the server is very bloated, the original deletion of the specified file is not difficult, on the unlink function!

Related articles: