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?

An Dorfer
  • 1,178
  • 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? –  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

2 Answers2

11

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

xlecoustillier
  • 281
  • 4
  • 11
  • 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++ –  Dec 21 '12 at 14:22
  • See praveen answer. – xlecoustillier Dec 21 '12 at 14:24
  • @user1794794: Do you work alone on your project ? If not, maybe it comes from another editor too. – xlecoustillier Dec 21 '12 at 14:26
  • The best answer is that you should not be editing your deployed files manually in the web server's directory. – Andy Lester Dec 22 '12 at 20:48
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 :)