Removing a directory in php with rmdir()

The php function rmdir() enables developers to remove a directory from the file system. The process trying to delete the directory must have enough permissions and the directory must be empty. The rmdir() function requires a string representing the path to the directory to be deleted. It returns TRUE on success or FALSE on failure.

Example code:

rmdir( "mydir" );
<?php
if (!is_dir('exampledir')) {
    mkdir('exampledir');
}
 
rmdir('exampledir');
?>

Tags:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.