|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-23 06:57 UTC] rasmus at mindplay dot dk
[2008-04-23 07:36 UTC] pajoye@php.net
[2008-04-23 14:21 UTC] pajoye@php.net
[2008-04-24 07:53 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
Description: ------------ The behavior of rename() is inconsistent between Linux and Windows. On Linux, the rename() function is atomic - you can rename() one file over an existing file, and the replacement is atomic. On Windows, you cannot rename over an existing file. Reproduce code: --------------- <?php file_put_contents("file1.txt", "this is file 1"); file_put_contents("file2.txt", "this is file 2"); rename("file1.txt", "file2.txt"); echo "reading file 2: "; readfile("file2.txt"); ?> Expected result: ---------------- reading file 2: this is file 1 Actual result: -------------- On Linux: (CORRECT) reading file 2: this is file 1 On Windows: (INCORRECT) Warning: rename(file1.txt,file2.txt) [function.rename]: File exists in C:\Web3\test\rename\test.php on line 6 reading file 2: this is file 2