R4R Team working to provide free of cost for experienced and freshers

Tutorials | Examples|Interview Questions and Answers|Java Tutorials| C Tutorials | C++ Tutorials | Spring Tutorials| Hibernate Tutorials | JSP Tutorials | Servelets Tutorials| C# Tutorials | PHP Tutorials etc , Basics | Download Software | Data Types | Variables | Constant | Storage & Classes | Operators | Decisions Making | Loops | Functions| Numbers | Arrays | Pointers | String | Datastructure | Expressions | Preprocessor Statement | I/O | Exception Handling | OOPs Tutorial | Classes and object |C++ Inheritance Overloading | Polymorphism | Abstraction | Encapsulation | Interfaces | Multithreading etc

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