PHP rmdir() Function – Remove Directory



PHP rmdir() Function

Remove Directory in PHP

The rmdir() function is used to remove a directory from computer system.

rmdir() function syntax

<?php

rmdir(“directory_name”);

?>

rmdir() function Example

<?php

rmdir("meera");

?>

Above example we use rmdir() function to remove directory named with “meera” from computer system at php script folder.

PHP form script example to remove directory

<HTML>
<head>
<title>Remove Directory in PHP</title>
</head>
<body>
<FORM method="POST">
 Enter Directory Name : <input type="text" name="str"> <br/> <br/>
<input type="submit" name="Submit1" value="Remove Directory">
</FORM>

<?php
if(isset($_POST["Submit1"]))
{
 rmdir($_POST["str"]);
 echo "Directory Removed.";
}
?>
</body>
</HTML>

The output of remove directory using rmdir() php example is:

php directory function
PHP rmdir() function example for remove directory

 

Leave a Reply

Your email address will not be published. Required fields are marked *