I dont know the cause, but a solution would be to assign permissions to the folders with scripts that make them readonly so they can't be changed server side. Then you can give permissions to like you images/uploads/ folder (or whateva you need to be change via your scripts) Again not a reason for why it happened but something that can help prevent problems in the future.
It sounds like you might be switching between MS and *nix line ending style OSes. I for 1 never under any circumstance edit a file on a production server. It is best practice to edit the files in a development environment and only move tested code to a production environment.
The cpanel file editor seems like the prime suspect to me ... I don't see any difference between a file using windows and unix newlines on my installation. You can check w/ the "who all characters" button in notepad++, of course ...
The cpanel file editor seems like the prime suspect to me
Since I don't use the cPanel file editor, I can't see that being the cause for any changes. I mentioned cPanel's editor only because I used it to view the script after using notepad++'s built in ftp plugin to download the script for editing.
It makes more sense to suggest that something happened to the file during ftp transmission from the local machine to the server. But I can't accept that as I know that noteplad++ and fileziller ftp client are very commonly used in web development and yet this problem I have had tonight, I don't see others complaining of it and I've suffered with it on more than one occasion.
It is a rarity, but some of my scripts are 1000 lines of coding. The script in question this time was only around 200 lines but still a bulls ache having to fix it!
I think there are 2 many possible causes for me to narrow it down and so I am without faith that I will find the answer
Do you keep a local copy of your PHP files? Seems like if the error happened during transmission to the site (could it be the php file was uploaded in binary mode rather than ascii? I don't know if this would cause the problem), then you would still have your original local copy.
Most of my work and transferring is done via notepad++ which uses binary transfer mode as its default setting. It's only on the very odd occasion that I use filezilla since notepad++ has built in ftp. I have just checked the transfer mode setting in filezilla and it was set at auto so I've switched it to binary and hopefully (assuming that may have been the cause) I won't have anymore problems. Fingers crossed and touching wood!!