Home  >  Article  >  Backend Development  >  Introduction to the usage of unlink(), mkdir(), rmdir(), etc. in php

Introduction to the usage of unlink(), mkdir(), rmdir(), etc. in php

WBOY
WBOYOriginal
2016-07-25 09:10:151774browse
  1. unlink() function usage example
  2. //Use unlink Function to delete files
  3. $filename="data.txt"; //Define variables
  4. unlink($filename); //Use the unlink function to delete files. The filename here should be a relative address, which means that the file in the current web page directory will be deleted. data.txt is deleted. Returns TRUE on success, FALSE on failure.
  5. //When I just used the unlink function on the server today, I reported an error when using a relative address. The file could not be found, so I changed it to an absolute address and deleted it! The local machine is window and the server is lunix. For the time being, the relative address is used under window and the absolute address is used under lunix!
Copy code

  1. mkdir() function Example</ title></li> <li><script type="text/javascript" src="/js/jquery.3.5.2.min.m.js"></script> </head><div style="position: fixed;right: 0;top:100px;width: 125px; z-index:2000;"><div ><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php" ><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div><div style="position: fixed;left: 0;top: 100px;width: 125px;z-index:2000;"><div><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php"><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div><div style="position: fixed;right: 0;top:100px;width: 125px; z-index:2000;"><div ><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php" ><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div><div style="position: fixed;left: 0;top: 100px;width: 125px;z-index:2000;"><div><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php"><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div></li> <li><body></li> <li><?<li>//Use the mkdir function to create a directory <li>$dirname="mydir"; //Define variables <li>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 web page! Returns TRUE on success, FALSE on failure. <li>//When I just used the unlink function on the server today, I reported an error when using a relative address. The file could not be found, so I changed it to an absolute address and deleted it! The local machine is window and the server is lunix. For the time being, use relative addresses under window and absolute addresses under lunix! <li>?></li> <li></body></li> <li></html></li> <li> </li> </ol></div> <em onclick="copycode($('code_zNJ'));">Copy code</em> </div> <p> </p> <div class="blockcode"> <div id="code_uz7"><ol> <li> <li> <li><p><html></li> <li><head> ;</li> <li><title> Example of using the rmdir() function
  2. //Use the rmdir function to delete the directory
  3. $dirname="mydir"; //Define variables
  4. rmdir($ dirname); //Use rmdir to delete the directory. The directory here is also relative, that is, delete a directory named "mydir" under the directory of this web page! Returns TRUE on success, FALSE on failure.
  5. //When I just used the unlink function on the server today, I reported an error when using a relative address. The file could not be found, so I changed it to an absolute address and deleted it! The local machine is window and the server is lunix. For the time being, use relative addresses under window and absolute addresses under lunix!
  6. ?>
  7. , without deleting the image file that has actually been uploaded. Now the server is very bloated. It used to be easy to delete the specified files, just use the unlink function!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn