Today I was modifying someone else’s file when I noticed that when I uploaded it to the server it displayed horribly. All whitespace was gone, and in the place of newlines was ^M characters. Here’s a snapshot of how the file looked when I uploaded.
If I viewed it with ‘more filename.php’ I didn’t see the ^M but it looked as if the whole file was on one line, and some characters had been replaced by {. Strange.
It does not affect the server’s ability to run the file, but it does make maintenance a nightmare if you ever have to edit the file in the future.
I had been using Notepad++ (notepad plus plus) to edit it, and I had never had this problem with any of my files. Turned out the file had originally been made on a Mac, which caused these weird characters to show up (sometimes it happens on Windows too).
Luckily there’s an easy fix. With the file open in Notepad++, simply go to the Edit menu -> EOL Conversion -> Windows. It might also work if you choose Unix too. Then save the file, re-upload and you’re golden!
Hope that helps!
This helped me and I really appreciate this.. well done
Thanks for posting this. I struggled with searching for a fix to very cryptic parse errors (unexpected T_STRING, unexpected $end) until I found this. Most advice online says it must be a missing curly bracket.
thanks 🙂
Thanks dude
helped me too… Thanks for the quick and helpful instructions
Thank you!
thanks lot..this really helped.
Thanks a lot!!!
Thanks! I knew it was there but lost it.
thanks!!
Thank you!! this helped me:)
Thanks!!
thank you 🙂
Thank you. This was really helpful !!