插入额外行的PHP文件?

I work on a Windows 7 machine and Notepad++ for a number of tasks. I have noticed that when I work with someone on a Mac who tries to edit a file, and then I access it later, there are always extra lines, sometimes missing lines, white space is all crazy. Usually extra lines.

Sometimes, there fewer lines or code is just collapsed as if all white space were removed.

I'm certain there isn't a prank involved, as it has happened a number of times over the years. I'm just finally curious enough to ask if anyone knows what causes this?

This is probably caused by the EOL or end-of-line character that you have selected in your editor. I also code on a Windows 7 machine, but have to push my files to UNIX where if I view the files, I will see ^M's or other strange characters in VI. If I recall correctly, go to Edit -> EOL Conversion and convert to UNIX/MAC. Just be sure to always set your EOL to UNIX and you shouldn't see the issue anymore.

Here's a link to a similar topic on SO: https://stackoverflow.com/questions/2889163/eol-in-notepad-and-notepad

What may be happening is that the Mac user is encoding the file in a slightly different way. Notepad++ is readying the file, but is not expecting to have to handle a Mac encoded file -- thus it renders oddly.

For example, the software may be converting tabs to spaces. Another example is the special characters used between systems, such as:


 = CR (Carriage Return) - used as a new line character in Unix
 = LF (Line Feed) - used as a new line character in Mac OS

 = CR + LF - used as a new line character in Windows

That's my thought.

That happens when you download a file that it's in Linux to a Windows throught FTP ASCII, you can download the files with FileZilla selecting:

Transfer -> Transfer Type -> Binary

That way the EOLs transfers just fine.