尊龙凯时人生就是搏

thinkphpÔõÑùɾ³ýÎļþ¼Ð

Ò»¡¢É¾³ý¿ÕÎļþ¼Ð

Ҫɾ³ýÒ»¸ö¿ÕµÄÎļþ¼Ð£¬ÎÒÃÇ¿ÉÒÔʹÓÃPHPÄÚÖõÄrmdir()º¯Êý£¬Ëü¿ÉÒÔÖ±½Óɾ³ýÒ»¸ö¿ÕÎļþ¼Ð¡£ÔÚThinkPHPÖУ¬ÎÒÃÇÖ»ÐèҪʹÓÃrmdir()º¯ÊýµÄ·¾¶²ÎÊý£¬±ã¿ÉÒÔɾ³ýÖ¸¶¨µÄÎļþ¼Ð¡£ÀýÈ磺

$path = './test'; //Ҫɾ³ýµÄÎļþ¼Ð·¾¶
if(is_dir($path)){
    rmdir($path);
}

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄʾÀýÖУ¬Ê×ÏÈÎÒÃǽç˵ÁËҪɾ³ýµÄÎļþ¼Ð·¾¶£¬È»ºóʹÓÃis_dir()º¯ÊýÅжϴË·¾¶ÊÇ·ñΪһ¸öĿ¼£¬ÈôÊÇÊÇĿ¼¾ÍÖ´ÐÐrmdir()º¯ÊýÀ´É¾³ýËü¡£ÐèҪעÖصÄÊÇ£¬ÕâÖÖÒªÁìÖ»ÄÜɾ³ý¿ÕÎļþ¼Ð£¬ÈôÊÇÎļþ¼ÐÖл¹±£´æÎļþ»ò×ÓÎļþ¼Ð£¬ÔòÎÞ·¨É¾³ý¡£

¶þ¡¢É¾³ý·Ç¿ÕÎļþ¼Ð

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÈôÊÇҪɾ³ý·Ç¿ÕÎļþ¼Ð£¬ÎÒÃÇ¿ÉÒÔʹÓÃdelDir()º¯ÊýÀ´ÊµÏÖ£¬ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʵÏÖ£º

function delDir($path){
    if(is_dir($path)){
        if ($dh = opendir($path)){
            while (($file = readdir($dh)) !== false){
                if ($file != '.' && $file != '..'){
                    $fullpath = $path.'/'.$file;
                    if(!is_dir($fullpath)){
                        unlink($fullpath);
                    }else{
                        delDir($fullpath);
                    }
                }
            }
            closedir($dh);
            rmdir($path);
        }
    }
}

µÇ¼ºó¸´ÖÆ

delDir()º¯ÊýµÄ×÷ÓÃÊÇɾ³ýĿ¼£¬Ëüͨ¹ýµÝ¹éŲÓÃ×ÔÉí£¬ÏÈɾ³ýĿ¼ÖеÄËùÓÐÎļþ£¬È»ºóÔÙɾ³ýÕâ¸öĿ¼¡£ÏêϸʵÏÖÒªÁìÊÇÊ×ÏÈʹÓÃopendir()º¯Êý·­¿ªÖ¸¶¨Ä¿Â¼£¬È»ºóʹÓÃreaddir()º¯Êý¶ÁȡĿ¼ÖÐËùÓÐÎļþºÍÎļþ¼Ð£¬ÅжÏËüÃÇÊÇ·ñΪ.ºÍ..£¬ÈôÊDz»ÊÇÔòÒÔͬÑùµÄ·½·¨¾ÙÐд¦Àí¡£

ÈôÊÇÊÇÎļþ£¬Ö±½ÓʹÓÃunlink()º¯Êýɾ³ý£»ÈôÊÇÊÇÎļþ¼Ð£¬ÔòµÝ¹éŲÓÃdelDir()º¯Êýɾ³ýÕâ¸öÎļþ¼Ð¼°ÆäÄÚÈÝ¡£×îºóÔÙʹÓÃrmdir()º¯Êýɾ³ýÕâ¸ö¿ÕĿ¼¡£

ÒÔÉϾÍÊÇthinkphpÔõÑùɾ³ýÎļþ¼ÐµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ