Introduction to unlink (), mkdir (), rmdir (), and other methods in php

Source: Internet
Author: User
Tags lunix
The unlink () function deletes files, the mkdir () function creates directories, and the rmdir () function deletes directories. these methods are often used in file-related processing methods, you may want to know about unlink () function deletion files, mkdir () function creation directories, and rmdir () function deletion directories.
Copy codeThe code is as follows:


Unlink () function use instance


// Use the unlink function to delete an object
$ Filename = "data.txt"; // defines the variable
Unlink ($ filename); // delete the file with unlinklinks. the filenameshould be the relative address, and the data.txt under the current webpage directory should be deleted. If the call succeeds, TRUE is returned. if the call fails, FALSE is returned.
// When I first used the unlink function on the server today, an error is reported when I used the relative address. the file cannot be found, so I changed it to an absolute address and deleted it! The host is Windows and the server is lunix. The relative address is used in the window, and the absolute address is used in the lunix! Let's take a look. is that the case? help confirm it again!




The mkdir () function uses an instance.


// Use the mkdir function to create a directory
$ Dirname = "mydir"; // defines the variable
Mkdir ($ dirname, 0700); // use mkdir to create a directory. the directory here is also relative. create a directory named "mydir" under the Directory of this webpage! If the call succeeds, TRUE is returned. if the call fails, FALSE is returned.
// When I first used the unlink function on the server today, an error is reported when I used the relative address. the file cannot be found, so I changed it to an absolute address and deleted it! The host is Windows and the server is lunix. For now, the relative address is used in the window, and the absolute address is used in lunix! Let's take a look. is that the case? help confirm it again!
?>




The rmdir () function uses an instance.


// Use the rmdir function to delete a directory
$ Dirname = "mydir"; // defines the variable
Rmdir ($ dirname); // use rmdir to delete the directory. the directory here is also relative to the directory on this page. delete the directory named "mydir! If the call succeeds, TRUE is returned. if the call fails, FALSE is returned.
// When I first used the unlink function on the server today, an error is reported when I used the relative address. the file cannot be found, so I changed it to an absolute address and deleted it! The host is Windows and the server is lunix. For now, the relative address is used in the window, and the absolute address is used in lunix! Let's take a look. is that the case? help confirm it again!
?>



Haha, simple application! In the system, images, documents, and so on are always required to be uploaded. in the background management, records are deleted without deleting the actually uploaded images. Now the server is very bloated, it is not difficult to delete the specified file, just like the unlink function!

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.