note 88474 deleted from function.copy by danbrown

From: Date: Mon, 26 Jan 2009 17:16:03 +0000
Subject: note 88474 deleted from function.copy by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149786@lists.php.net to get a copy of this message
Note Submitter: niels at NOSPAM dot nielsbom dot com ---- The dir_copy() function given below has flaws. 1) It tries to be recursive but then it calls itself by using dircopy() instead of dir_copy(). 2) The call to itself has the wrong number of parameters. 3) It uses if/else statements in one line without using parentheses, which can become confusing quickly and is imho mostly advised against. 4) $ret is not initialized, this will trigger a warning if the first entity encountered is a directory. Another suggestion I have is using more descriptive variable names. $ow, $fifail,$res,$ret and $mod aren't descriptive (to me in any case). A last suggestion (but this would be a nice-to-have) is copying dirs first and then files, so not straight recursion. Straight recursion in this case can be a bit confusing, imho.

« previous php.notes (#149786) next »