English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP rmdir() Function Usage and Example

PHP Filesystem Reference Manual

The rmdir() function can delete an empty directory and return true on success, and return false on failure.

Syntax

bool rmdir ( string $dirname [, resource $context ] )

Try to delete the directory specified by dirname. The directory must be empty and have the corresponding permissions. An E_WARNING level error will be generated if it fails.

Online Example

<?php
   if(!is_dir("/PhpProject/examples")) {
      mkdir("/PhpProject/examples");
   }
   rmdir("/PhpProject/examples");
   echo "The directory has been successfully deleted!!!";
?>

Output Result

The directory has been successfully deleted!!!

PHP Filesystem Reference Manual