Home > Article > Backend Development > How to use php rmdir function
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.
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!