How to copy or delete a directory PHP in PHP is used to copy files, no corresponding copying directory, in fact, this is also very simple, mainly using MKDIR () and Copy () combined with future return For deletion, it is also use RMDIR () and unlink () to deliver Copy Directory: Function CopyDir ($ Source, $ Destination) {$ Result = true; if (! Is_dir ($ source)) {Trigger_ERROR ('Invalid Parameter', E_USER_ERROR);} f (! Is_dir ($ destination)) {if (! MKDIR ($ Destination, 0700)) {Trigger_ERROR ('Invalid Parameter', E_USER_ERROR);}} $ hand = OpenDir ($ Source); While ($ file = readdir)! == false) {if ($ file! = '.' && $ file! = '..') {$ src = $ source. Directory_separator. $ $ DTN = $ DESTINATION. DIRECTORY_SEPArator. $ file; if (is_dir ($ src)) {CopyDir ($ SRC, $ DTN);} else {if (! Copy ($ src, $ dtn)) {$ Result = False; Break;}}}} closedir ($ hand); RETU Rn $ Result;}?> Delete Directory code: phpfunction removedir ($ dirName) {$ result = false; if (! is_dir ($ dirName) {TRIGGER_ERROR ('Invalid Parameter', E_USER_ERROR);} $ handle = OpenDir ($ DIRNAME); WHILE (($ FILE = ReadDir ($ Handle))! == false) {if ($ file! = '.' && $ file! = '..') {$ dir = $ dirname. Directory_seParetor. $ File; is_dir ($ dir): unlink ($ dir);}} closedir ($ hand); $ results = rmdir ($ dirname)? True: false; return $ result;}? > Note: