Php deletes the file before recreating it. the file creation date is not updated.

Source: Internet
Author: User
The following code does not update the file creation date when php deletes and re-creates a file: PHPcodevar_dump (unlink (& quot; update1.log & quot ;)); // true $ handle = fopen (& quot; update1.log & quot;, & quot; w & quot ;); the file creation date is not updated when php deletes the file and re-creates it.
The code is as follows:
PHP code
  Var_dump (unlink ("update1.log"); // true $ handle = fopen ("update1.log", "w"); // create a file fwrite ($ handle, date ("Y-m-d H: I: s"); fclose ($ handle );


The expected result is that the creation time of update1.log can be changed to the time when the fopen () file is created.

The actual result is that the creation time of update1.log is always the time of the first creation, as if there was no unlink.

Puzzling ~

Could anyone please help me solve this problem ~

PS: My operating system is win7

------ Solution --------------------
A few upstairs are a bit taken for granted

The fact is indeed the same as that observed by the landlord, at least in the window system.

But this has nothing to do with php, and it is the reason for the file system.
It is estimated that the directory item is not cleared when the file is deleted (only the delete flag is used), and the original directory item is used when the file is created again.
It can be considered that the "file creation time" should be the time when the directory item was created.

Php has the function filectime to get the time.


------ Solution --------------------
Discussion

What I said upstairs makes sense. Does anyone know what the situation is in linux?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.