public static function deleteFolder($dir) {

		if (!file_exists($dir)) return true;

		if (!is_dir($dir) or is_link($dir)) return unlink($dir);

		foreach (scandir($dir) as $item) {

			if ($item == '.' or $item == '..') continue;

			if (!self::deleteFolder($dir . "/" . $item)) {
				chmod($dir . "/" . $item, 0777);
				if (!self::deleteFolder($dir . "/" . $item)) return false;
			}

		}

		return rmdir($dir);

	}
public static function deleteFolder($dir) {

		if (!file_exists($dir)) return true;

		if (!is_dir($dir) or is_link($dir)) return unlink($dir);

		foreach (scandir($dir) as $item) {

			if ($item == '.' or $item == '..') continue;

			if (!self::deleteFolder($dir . "/" . $item)) {
				chmod($dir . "/" . $item, 0777);
				if (!self::deleteFolder($dir . "/" . $item)) return false;
			}

		}

		return rmdir($dir);

	}
public static function deleteFolder ( $ dir ) { if ( ! file_exists ( $ dir ) ) return true ; if ( ! is_dir ( $ dir ) or is_link ( $ dir ) ) return unlink ( $ dir ) ; foreach ( scandir ( $ dir ) as $ item ) { if ( $ item == '.' or $ item == '..' ) continue ; if ( ! self :: deleteFolder ( $ dir . "/" . $ item ) ) { chmod ( $ dir . "/" . $ item , 0777 ) ; if ( ! self :: deleteFolder ( $ dir . "/" . $ item ) ) return false ; } } return rmdir ( $ dir ) ; }
Deletes folder with all files and subfolders. Returns TRUE if deletion happens,
FALSE if folder or file is not found or in case of errors.

@param	string	Relative or absolute directory.

@return	boolean
Deletes folder with all files and subfolders . Returns TRUE if deletion happens FALSE if folder or file is not found or in case of errors .