PHP Programing language

Using for Function Define recursive function to delete directories
Previous Home Next
<html>
<head>
<title>Define recursive function to delete directories </title>
</head>
<body>
<h1>Define recursive function to delete directories </h1>
<?php
 function delete_directory ($dir) 
 {
 if ($d = @opendir($dir)) 
 {
while (($file = readdir ($d)) != false) 
{
if (($file == ".") || ($file == "..")) continue;
if (is_dir($dir . '/' . $file))
delete_directory($dir . '/' . $file);
else
unlink($dir . '/' . $file);
 }
@closedir($d);
rmdir($dir);
      }
   }
$dir = "./Directory";
delete_directory($dir);
?>
</body>
</html>

 

Output

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: