Home  >  Article  >  Backend Development  >  10 recommended articles about the php rmdir() function

10 recommended articles about the php rmdir() function

怪我咯
怪我咯Original
2017-06-11 15:04:181048browse

First, let me introduce to you the rmdir() function. PHP rmdir() function rmdir - delete empty directory syntax: bool rmdir (string $dirname [, resource $context]) attempts to delete the directory specified by dirname. The directory must be empty and must have appropriate permissions. An E_WARNING level error will be generated on failure. Parameters: 1.dirname: path to the directory. 2.context: Support for context (Context) has been added in PHP 5.0.0. PHP rmdir() deletes a non-empty directory. As mentioned above, the rmdir() function can only delete empty directories. If it is a non-empty directory, you need to enter the directory first and use the unlink() function to delete every file in the directory. , then come back and delete this empty directory. If there are subdirectories in the directory and the directory is not empty, you need to use the recursive method. The source code of the custom recursive function to delete a directory is as follows:

1. php rmdir uses recursive function to delete non-empty directory instances detailed explanation

10 recommended articles about the php rmdir() function

Introduction: We all know that the php rmdir() function is used to delete empty directories, but if we want to delete a non-empty directory, we must delete the files or subdirectories in the non-empty directory. This article will tell you Introduce how to use recursive functions in php to delete non-empty directories. Friends who need it can refer to

2. rrmdir recursively delete directories and files in the directories in php

10 recommended articles about the php rmdir() function

Introduction: The rmdir that comes with PHP can only delete empty directories. This rrmdir can recursively delete directories and directories. All files, but be careful when using them, don’t delete all files

3. PHP delete files and folders using unlink() and rmdir() Use of a function

10 recommended articles about the php rmdir() function

##Introduction: Sometimes we need to use PHP to delete files and folders, PHP There are originally functions that can be implemented. Let’s simply record the code below so that it can be easily copied later.

4. python file management

10 recommended articles about the php rmdir() function

## Introduction: 1. os package The os package includes a variety of functions to implement many functions of the operating system. This package is very complex. Some commands of the os package are used for file management. We list the most commonly used ones here: mkdir(path) creates a new directory, path is a string representing the path of the new directory. Equivalent to the $mkdir command rmdir(path) to delete an empty directory, path is a string indicating the path of the directory you want to delete. Equivalent to the $rmdir command listdir(path) returns all files in the directory. Equivalent to...

5.

python file management

10 recommended articles about the php rmdir() function

Introduction: 1. os package The os package includes a variety of functions to implement many functions of the operating system. This package is very complex. Some commands of the os package are used for file management. We list the most commonly used ones here: mkdir(path) creates a new directory, path is a string representing the path of the new directory. Equivalent to the $mkdir command rmdir(path) to delete an empty directory, path is a string indicating the path of the directory you want to delete. Equivalent to the $rmdir command listdir(path) returns all files in the directory. Equivalent to...

6.

php rmdir uses a recursive function to delete non-empty directories

10 recommended articles about the php rmdir() function

Introduction: We all know that the php rmdir() function is used to delete empty directories, but if we want to delete a non-empty directory, we must delete the files or subdirectories in the non-empty directory , this article introduces how to use recursive functions in PHP to delete non-empty directories. Friends in need can refer to it. First, let me introduce you to the rmdir() function.

7. php folder operation

Introduction:: This article mainly introduces php folder operation. Those who are interested in PHP tutorials Students can refer to it.

8. PHP directory php php directory operation php mkdir multi-level directory

10 recommended articles about the php rmdir() function

Introduction: php, directory: PHP directory: directory operation to create a new directory mkdir (path, permissions, recursive creation) delete directory rmdir() move (rename) rename() gets directory contents //open Directory Directory handle = opendir() //Read directory filename = readdir(directory handle) Read the file names in sequence and move the file handle pointer downward at the same time. If it cannot be read, it returns false. //Close directory closedir() recursively reads directory contents

##9. How to retrieve files deleted from the Recycle Bin PHP, delete files and folders

Introduction: How to retrieve files deleted from the Recycle Bin: How to retrieve files deleted from the Recycle Bin and the use of the two functions unlink and rmdir in PHP deletion of files and folders

10. acronis disk director rrmdir php recursively deletes directories and files under the directory

Introduction: acronis disk director:acronis disk director rrmdir php Recursively delete directories and files under directories: Copy the code as follows: function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ( $object != “.” && $object != “..”) { if (filetype($dir.”/”.$objec

【Related Q&A recommendations】:

node.js - It is known how to delete folders in nodejs but how to delete files

The problem of failed renaming directory under php

The above is the detailed content of 10 recommended articles about the php rmdir() function. For more information, please follow other related articles on the PHP Chinese website!

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