3

I am working on one PHP project, and I am having some files for that. Some of the files have anextension as

file_name.php~

What does it mean and how do those files get created?

migrated from stackoverflow.com Dec 21 '12 at 15:13

This question came from our site for professional and enthusiast programmers.

  • Which editor are you using? ~ is a common postfix for auto-saved files. – dutt Dec 21 '12 at 14:19
  • Indeed, either an auto-save or a flag to show someone else has the file open (like MSOffice does). – Brad Christie Dec 21 '12 at 14:19
  • @dutt: i am using notepad++. but with this how such files generates? – user1794794 Dec 21 '12 at 14:24
  • Notepad++ can also be configured to backup to a custom directory away from your current files. Or you can turn off the backup altogether. – MrWhite Dec 21 '12 at 14:30
11

Those are backup files created by the text editor you are using (or one of the people working on the same project).

  • 12
    ... and they're very dangerous to have online because they may not be parsed by the PHP interpreter, revealing the source code including any passwords that may be contained therein. – Pekka 웃 Dec 21 '12 at 14:20
  • And @Pekka is totally right! – xlecoustillier Dec 21 '12 at 14:21
  • 2
    Yes - although many default web server configurations include rules to forbid access to files beginning or ending in ~, you must not rely on that! Remove them from web-accessible locations immediately. – Michael Dec 21 '12 at 14:21
  • @X.L.Ant: how that back up generates? are there any steps to create it or automatically editor creates it. and specifically which editor. i am using notepad++ – user1794794 Dec 21 '12 at 14:22
  • See praveen answer. – xlecoustillier Dec 21 '12 at 14:24
5

When you are working with files, editing them, the editor(almost all of them) creates a copy of it with names like you provided and does the editing on that file. Upon saving the file the changes are saved to the original files.

These files are generally hidden from the user. You are seeing it probably because the option to show hidden files is turned on.

When you quit from your text editor, that temporary file gets deleted.

Finally, You don't need to worry about the creation of those files :)

NOTE: JUST MAKE SURE YOU DON'T UPLOAD THEM TO THE SERVER WHICH CAN BE A SECURITY ISSUE AS DISCUSSED IN THE COMMENTS :)

  • Welcome :) And don't worry about those files :p – Praveen Puglia Dec 21 '12 at 14:27
  • 2
    @praveen: You should worry about those files if you accidentally upload them to your live server (as Pekka points out on the other answer). – MrWhite Dec 21 '12 at 14:32
  • Yes! that is a point to worry! I just meant to tell him not to worry about why those files are created. :p – Praveen Puglia Dec 21 '12 at 14:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.