generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 2022-12-15-phpstrom莫名删除空格的问题.md
- Loading branch information
1 parent
fe89799
commit bb48733
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
layout: post | ||
title: "phpstrom莫名删除空格的问题" | ||
date: 2023-12-06 13:29:20 +0800 | ||
categories: | ||
- 杂项 | ||
tags: | ||
- php | ||
- phpstrom | ||
--- | ||
阅读此文可以解决以下问题: | ||
- php代码中的空格莫名消失不见 | ||
- phpstrom自动删除变量定义末尾的不可见字符 | ||
|
||
最近帮朋友修改一个财务软件,客户要新增一个功能。使用phpstrom进行开发。 | ||
|
||
修改完成给客户验收的过程中,客户反应有一个txt表格导出功能错误了。之前是好的(这个功能是导出一个txt格式的表格,然后在其他软件导入)。 | ||
|
||
这次是新增功能,老的功能碰都没碰过,怎么能有问题呢?我心里OS道 | ||
|
||
下班后我立马用当前系统导出TXT,然后还原代码再导出一个txt, | ||
|
||
接着使用文本分析软件一看,MD居然有很多不同的地方,最多的地方是表格标题的字符串定义后面的空格; | ||
|
||
老系统标题后有几个空格,但是新系统代码没有了。卧槽,这TM咋回事。蒙蔽10分钟 | ||
|
||
后面查明,是phpstrom自动删除每行的空格,这个J8在搞事。 | ||
|
||
这里举例: | ||
```php | ||
// 注意这段代码, 只是一个变量定义,定义了一个多行的字符串 | ||
// 如果在b处后面新增几个空格,然后保存. 重新打开文件后会发现空格神奇消失 | ||
$a = "a | ||
b | ||
c" | ||
``` | ||
|
||
|
||
解决方案当然是:关了就好 | ||
|
||
关闭地方如下图: | ||
`禁用Settings/Preferences | Editor | General | Trim trailing spaces on Save选项(设置为无")` | ||
或者: | ||
`禁用Settings/Preferences | Editor | General | Strip trailing spaces on Save选项(设置为None")` | ||
|
||
|
||
|
||
如上图,这里IDEA是真的坑! | ||
|
||
值得一提的是,如果你项目里面有`.editorconfig`文件,请在这里修改`trim_trailing_whitespace=false` | ||
|
||
这个文件将会覆盖默认值!!! | ||
|
||
收队!!!! | ||
|
||
|