Usage of unlink (), mkdir (), and rmdir () in php

Source: Internet
Author: User
Tags lunix
Usage of unlink (), mkdir (), and rmdir () in php

  1. Unlink () function use instance
  2. // Use the unlink function to delete an object
  3. $ Filename = "data.txt"; // defines the variable
  4. 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.
  5. // 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!

  1. The mkdir () function uses an instance.
  2. // Use the mkdir function to create a directory
  3. $ Dirname = "mydir"; // defines the variable
  4. 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.
  5. // 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!
  6. ?>

  1. The rmdir () function uses an instance.
  2. // Use the rmdir function to delete a directory
  3. $ Dirname = "mydir"; // defines the variable
  4. 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.
  5. // 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!
  6. ?>

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.