protected function deleteRecursive($path)
    {
        if (is_file($path) || is_link($path)) {
            return unlink($path);
        }
        $success = true;
        $dir = dir($path);
        while (($entry = $dir->read()) !== false) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $entry_path = $path . '/' . $entry;
            $success = static::deleteRecursive($entry_path) && $success;
        }
        $dir->close();

        return rmdir($path) && $success;
    }
protected function deleteRecursive($path)
    {
        if (is_file($path) || is_link($path)) {
            return unlink($path);
        }
        $success = true;
        $dir = dir($path);
        while (($entry = $dir->read()) !== false) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $entry_path = $path . '/' . $entry;
            $success = static::deleteRecursive($entry_path) && $success;
        }
        $dir->close();

        return rmdir($path) && $success;
    }
protected function deleteRecursive ( $ path ) { if ( is_file ( $ path ) || is_link ( $ path ) ) { return unlink ( $ path ) ; } $ success = true ; $ dir = dir ( $ path ) ; while ( ( $ entry = $ dir -> read ( ) ) !== false ) { if ( $ entry == '.' || $ entry == '..' ) { continue ; } $ entry_path = $ path . '/' . $ entry ; $ success = static :: deleteRecursive ( $ entry_path ) && $ success ; } $ dir -> close ( ) ; return rmdir ( $ path ) && $ success ; }
Helper method to remove directories and the files they contain.

@param string $path
The directory or file to remove. It must exist.

@return bool
TRUE on success or FALSE on failure.
Helper method to remove directories and the files they contain .