Introduction to the use of unlink (), mkdir (), rmdir () and other methods in PHP _php tips

Source: Internet
Author: User
Tags mkdir lunix
Unlink () function deletes file, mkdir () function creates directory, RmDir () function deletes directory
Copy Code code as follows:

<title>unlink () function Use example </title>
<body>
?
To delete a file using the Unlink function
$filename = "Data.txt"; Defining variables
Unlink ($filename); Delete the file with the unlink function, where filename should be the relative address, that is, delete the data.txt from the current page directory. Returns TRUE if successful, and returns FALSE if it fails.
Today just on the server using the unlink function, with the relative address of the error, can not find the file, and then changed to absolute address, deleted! This machine is window and the server is LUnix. Temporarily is the window under the relative address, LUnix under the absolute address! Everyone used to see if this is the case, and then help confirm!
</body>
<title>mkdir () function Use example </title>
<body>
?
Create a table of contents using the MkDir function
$dirname = "Mydir"; Defining variables
mkdir ($dirname, 0700); Use mkdir to create a directory, where the directory is also relative to the page in the directory to create a directory called "Mydir"! Returns TRUE if successful, and returns FALSE if it fails.
Today just on the server using the unlink function, with the relative address of the error, can not find the file, and then changed to absolute address, deleted! This machine is window and the server is LUnix. Temporarily is the window under the relative address, LUnix under the absolute address! Everyone used to see if this is the case, and then help confirm!
?>
</body>
<title>rmdir () function Use example </title>
<body>
?
To delete a directory using the RmDir function
$dirname = "Mydir"; Defining variables
RmDir ($dirname); Use RmDir to delete the directory, where the directory is also relative to this page in the directory of a directory named "Mydir" Delete! Returns TRUE if successful, and returns FALSE if it fails.
Today just on the server using the unlink function, with the relative address of the error, can not find the file, and then changed to absolute address, deleted! This machine is window and the server is LUnix. Temporarily is the window under the relative address, LUnix under the absolute address! Everyone used to see if this is the case, and then help confirm!
?>
</body>

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

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.