|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-22 18:14 UTC] iliaa@php.net
[2005-06-27 01:19 UTC] tony2001@php.net
[2005-07-20 21:26 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 19:00:01 2025 UTC |
Description: ------------ Copying a file into itself causes the source file to be truncate to 0 bytes. copy("test", "test"); // test.txt -> 0 You can't avoid this problem just by comparing the filenames, since one could be a symlink pointing to the other. The following would destroy test1 if test2 is a link to test1: copy("test1", "test2"); Reproduce code: --------------- copy("test", "test"); Expected result: ---------------- Nothing happens or a file open error. Actual result: -------------- Contents in source file is lost.