note 119408 added to function.rename
| From: | _php_ | Date: | Mon, 30 May 2016 16:15:57 +0000 |
| Subject: | note 119408 added to function.rename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205622@lists.php.net to get a copy of this message | ||
If $source is a valid folder, what do you think this does:
<?php
rename($source, '@');
?>
In 99% of the time you will get a warning, and $source remains untouched.
However, if you're working on Windows, and on a mapped network drive occasionally $source will
be moved to folder '@' which will be located at PHP's working directory.
How about this:
<?php
rename($source, $source . '\folder1');
?>
This makes $source inaccessible.
Of course, it's stupid to move $source into a sub-folder like that. I'd expect an error.
Yet, no error or warning. And the script "freezes".
I had few instances where rename simply deleted files & folders. I have not been able figure out
why.
In a nut shell, be-careful when using rename.
----
Server IP: 72.52.91.14
Probable Submitter: 173.35.105.59
----
Manual Page -- http://php.net/manual/en/function.rename.php
Edit -- https://master.php.net/note/edit/119408
Del: integrated -- https://master.php.net/note/delete/119408/integrated
Del: useless -- https://master.php.net/note/delete/119408/useless
Del: bad code -- https://master.php.net/note/delete/119408/bad+code
Del: spam -- https://master.php.net/note/delete/119408/spam
Del: non-english -- https://master.php.net/note/delete/119408/non-english
Del: in docs -- https://master.php.net/note/delete/119408/in+docs
Del: other reasons-- https://master.php.net/note/delete/119408
Reject -- https://master.php.net/note/reject/119408
Search -- https://master.php.net/manage/user-notes.php