简体   繁体   English

php 文件不断出现双换行符

[英]php files keep getting double line breaks

I code custom plugins for Wordpress.我为 Wordpress 编写了自定义插件。 I use Microsoft Visual Studio Code to do the coding and FileZilla to transfer the files.我使用 Microsoft Visual Studio Code 进行编码,使用 FileZilla 传输文件。

With almost every php file that I code, I'm not sure if it's something that's happening when I download my plugin and then upload it to a new site, or if it's when I install it on a new site from a zip file, but when I check the code I find that the entire code has ended up with double line breaks!对于我编码的几乎每个 php 文件,我不确定当我下载插件然后将其上传到新站点时是否发生了这种情况,或者当我从 zip 文件将其安装到新站点时是否发生了这种情况,但是当我检查代码时,我发现整个代码都以双换行符结尾!

ie, IE,

function gdvcaddons_admin() {
    add_menu_page("GD Addons Settings", "GD Addons Settings", "administrator", "gdvcaddons-settings", "gdvcaddons_settings_page");
}
add_action('admin_menu', 'gdvcaddons_admin');
// DEFINE OPTIONS TO BE SAVED //
function gdvcaddons_settings() {
    register_setting( 'gdvcaddons-settings-group', 'recaptcha_site_key' );
    register_setting( 'gdvcaddons-settings-group', 'recaptcha_private_key' );
}
add_action( 'admin_init', 'gdvcaddons_settings' );
// DECLARE FILE CONTAINING OPTIONS FORM //
function gdvcaddons_settings_page(){
  include('inc/gdvcaddons-settings-form.php');
}

Becomes:变成:

function gdvcaddons_admin() {

    add_menu_page("GD Addons Settings", "GD Addons Settings", "administrator", "gdvcaddons-settings", "gdvcaddons_settings_page");

}

add_action('admin_menu', 'gdvcaddons_admin');

// DEFINE OPTIONS TO BE SAVED //

function gdvcaddons_settings() {

    register_setting( 'gdvcaddons-settings-group', 'recaptcha_site_key' );

    register_setting( 'gdvcaddons-settings-group', 'recaptcha_private_key' );

}

add_action( 'admin_init', 'gdvcaddons_settings' );

// DECLARE FILE CONTAINING OPTIONS FORM //

function gdvcaddons_settings_page(){

  include('inc/gdvcaddons-settings-form.php');

}

It is quite a problem because it keeps causing Yoast SEO's sitemaps to break and I keep having to open all my php files via FTP and do regex search/replace "\s\n" with "\n".这是一个相当大的问题,因为它一直导致 Yoast SEO 的站点地图中断,我一直不得不通过 FTP 打开我所有的 php 文件,并使用“\n”进行正则表达式搜索/替换“\s\n”。

Does anyone have any idea what might be causing this issue and how I can prevent it from reoccurring?有谁知道可能导致此问题的原因以及如何防止它再次发生?

Try to change transfer type尝试更改transfer type

For single FTPs对于单个 FTP

在此处输入图像描述

Global Settings.全局设置。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM