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
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/
The most elegant solution would be coding with linux instead of windows - because put simply: linux uses \n for a linebreak, windows uses \r\n
most editors that are more advanced than notepad support converting file from windows-style to linux-style. just browse through their respective menus.
and to provide a solution written in PHP:
<?php
$input = file_get_contents("old.php");
$data = str_replace("\r\n", "\n", $input);
file_put_contents("new.php");
your replacement probably didn't work because most regular editors use the backslash just as the character backslash and don't interpret \n as escape-sequence for a newline-character, but simply as a backslash and an n.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With