protected function clearDirectory($path)
    {
        $iterator = new \DirectoryIterator($path);

        /** @var \DirectoryIterator $fileinfo */
        foreach ($iterator as $fileinfo) {
            if ($fileinfo->isDot()) {
                continue;
            }

            if ($fileinfo->isFile() || $fileinfo->isLink()) {
                @unlink($fileinfo->getPathname());
            } elseif ($fileinfo->isDir()) {
                $this->clearDirectory($fileinfo->getPathname());
            }
        }
    }
protected function clearDirectory($path)
    {
        $iterator = new \DirectoryIterator($path);

        /** @var \DirectoryIterator $fileinfo */
        foreach ($iterator as $fileinfo) {
            if ($fileinfo->isDot()) {
                continue;
            }

            if ($fileinfo->isFile() || $fileinfo->isLink()) {
                @unlink($fileinfo->getPathname());
            } elseif ($fileinfo->isDir()) {
                $this->clearDirectory($fileinfo->getPathname());
            }
        }
    }
protected function clearDirectory ( $ path ) { $ iterator = new \ DirectoryIterator ( $ path ) ; /** @var \DirectoryIterator $fileinfo */ foreach ( $ iterator as $ fileinfo ) { if ( $ fileinfo -> isDot ( ) ) { continue ; } if ( $ fileinfo -> isFile ( ) || $ fileinfo -> isLink ( ) ) { @ unlink ( $ fileinfo -> getPathname ( ) ) ; } elseif ( $ fileinfo -> isDir ( ) ) { $ this -> clearDirectory ( $ fileinfo -> getPathname ( ) ) ; } } }
Recursively clears the specified directory.

@param string $path the directory path
Recursively clears the specified directory .