Home  >  Article  >  Backend Development  >  How to use php rmdir function

How to use php rmdir function

藏色散人
藏色散人Original
2019-02-20 15:51:153134browse

The rmdir() function is a built-in function in PHP, used to delete empty directories. The syntax is rmdir(dir,context), which takes the directory to be deleted as a parameter. It returns True when successful and False when failed. NOTE: The directory must be empty and you must have the relevant permissions required to delete the directory.

How to use php rmdir function

php How to use the rmdir() function?

Function: Delete empty directories.

Syntax:

rmdir(dir,context)

Parameters:

dir: Required. Specifies the directory to be deleted.

context: Required. Specifies the environment for a file handle. Context is a set of options that modify the behavior of the stream.

Description: Try to delete the directory specified by dir. The directory must be empty and must have appropriate permissions.

php rmdir() function example

<?php
$dir = rmdir("newFile");
if($dir)
{
    echo "目录删除成功";
}else{
    echo "目录删除失败";
}
?>

This article is an introduction to the PHP rmdir function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use 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