php validation issue End of line character is invalid; expected "\n" but found "\r\n"

NewUser picture NewUser · Feb 10, 2016 · Viewed 17.8k times · Source

I am using Sublime text editor. I want to validate a Prestashop module in the validator. But it showing the error like End of line character is invalid; expected "\n" but found "\r\n" This line of code only contains <?php. I have searched and replace with "\r\n" with "\n" from different editors. But its not working at all. Can you tell me how to solve this issue? Any help and suggestions will be really appreciable. Thanks

Answer

Nate I picture Nate I · Feb 10, 2016

This is an operating system issue. This happens when you're coding cross-platform. Operating systems have different ways of interpreting an end of line. Here, this may help:

Convert line endings

Also, sublime has a solution for this as well. If you're coding for Unix, make sure you change your line-breaks for Unix. View->Line Endings->Unix

This solution is actually a bit more in-depth:

http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/