Home  >  Article  >  Backend Development  >  How to delete directory custom functions in PHP

How to delete directory custom functions in PHP

不言
不言Original
2018-07-11 16:33:551996browse

This article mainly introduces how to delete directory custom functions in PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it.

function rm_dir($dir)
{
    if($handle = opendir($dir))
    {
        while (false !== ($item = readdir($handle)))
        {
            if($item != "." && $item != "..")
            {
                if(is_dir("$dir/$item"))
                {
                    rm_dir("$dir/$item");
                }
                else
                {
                    unlink("$dir/$item");
                    echo "removing $dir/$item
";
                }
            }
        }
        closedir($handle);
        rmdir($dir);
        echo "removing$dir
";
    }
}

The above is the entire content of this article. , I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to PHP’s random probability calculation function

The above is the detailed content of How to delete directory custom functions in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn