Search code examples
phpcommand-linecommand-promptphpcodesniffer

End of line character is invalid


I checked my code using php codesniffer and got this error:

enter image description here

It says the error happened in the first line of the code, but all I have in the first line of my code is a php opening tag:

<?php

Is there a program to show these characters and fix it? I also tried phpcbf command but it doesn't appear to work:

enter image description here


Solution

  • I assume you are using windows. Your file uses unix lineendings ("\n") Windows uses ("\r\n")

    you could convert the lineendings in the commandline with

    type input_filename | more /P > output_filename
    

    or open your sourcefiles with an editor like notepad++ and change lineendings to windows