Visual Studio Code中的PHP提示错误:End of line character is invalid

导语:叶子最近安装了微软的Visual Studio Code来写PHP代码,才写了几行代码,phpcs就提示:End of line character is invalid; expected “\n” but found “\r\n”。

错误描述

End of line character is invalid; expected "\n" but found "\r\n"。

错误原因

PHP结尾的换行符应该是”\n”,但现在是”\r\n”。

处理方法

我们可以在网页https://code.visualstudio.com/docs/getstarted/settings中找到这句话:


  // The default end of line character. Use \n for LF and \r\n for CRLF.
  "files.eol": "\r\n",

意思是在Visual Studio Code中,以”\n”结尾,需要使用 LF 模式,如果要以 “\r\n” 结尾,需要使用 CRLF模式。

LF/CRLF切换方法

我们可以在Visual Studio Code的窗口右下方底部状态栏上,看到CRLF的标签,点击它,可以切换为 LF 模式。然后,错误就消失了。

结束

你学会了吗?


Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/71.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

目前在“Visual Studio Code中的PHP提示错误:End of line character is invalid”上有2条评论


  1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

    Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

    Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/52.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
    刘浪潮说道:

    刚好解决了遇到的这个问题


    1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

      Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

      Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/79.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
      编辑 杨说道:

      好的,你觉得有用就行

发表评论

邮箱地址不会被公开。 必填项已用*标注