PHP rmdir() Function

PHP set_file_buffer() Function
PHP rewind() Function

In this article, you will learn how to remove an empty folder in PHP. The rmdir() function in PHP removes an empty directory.

what is the syntax of the RMDIR function in php?

rmdir(dir, context)
ParameterDescription
dirRequired. Specifies the path to the directory to be removed
contextOptional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream
PHP rmdir() method

examples of the RMDIR function

Example 1. In this example, we remove “images” directory.

<?php
$path = "images";
if(!rmdir($path)) {
  echo ("Could not remove $path");
}
?>
PHP set_file_buffer() Function
PHP rewind() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top