note 88474 added to function.copy
| From: | niels at NOSPAM dot nielsbom dot com | Date: | Mon, 26 Jan 2009 12:47:31 +0000 |
| Subject: | note 88474 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149772@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 83.137.20.135
Probable Submitter: 92.65.43.58
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- https://master.php.net/note/edit/88474
Del: integrated -- https://master.php.net/note/delete/88474/integrated
Del: useless -- https://master.php.net/note/delete/88474/useless
Del: bad code -- https://master.php.net/note/delete/88474/bad+code
Del: spam -- https://master.php.net/note/delete/88474/spam
Del: non-english -- https://master.php.net/note/delete/88474/non-english
Del: in docs -- https://master.php.net/note/delete/88474/in+docs
Del: other reasons-- https://master.php.net/note/delete/88474
Reject -- https://master.php.net/note/reject/88474
Search -- https://master.php.net/manage/user-notes.php