Friday, November 7, 2008

How to delete a directory using php - rmdir()

Lets see how can we delete a folder using php.
You can use rmdir() function to do this task, before using this function you should remember that you can only delete empty folders


<?php

$path = 'path to directory'

//First Check if deleting a directory
if(is_dir($path))
{
//remove directory
if(rmdir($path))
{
echo 'Deleted';
}
else
{
echo 'error';
}
}
else
{
echo 'Not a directory';
}
?>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

No comments:

Post a Comment