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.
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> unlink () function instance </title>
</Head>
<Body>
<?
// 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!
</Body>
</Html>
<Html>
<Head>
<Title> mkdir () function use instance </title>
</Head>
<Body>
<?
// 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!
?>
</Body>
</Html>
<Html>
<Head>
<Title> rmdir () function use instance </title>
</Head>
<Body>
<?
// 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!
?>
</Body>
</Html>

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.