小编Mor*_*adi的帖子

php写文件将单引号转换为双引号

我的代码是这样的

$fp = fopen('text.php', 'w');
fwrite($fp, $_POST['code']);
fclose($fp);
Run Code Online (Sandbox Code Playgroud)

但如果$_POST['code']单引号(')输出将是2个单引号,例如:
如果输入是'test'

如果我们打开text.php输出会

''测试''

我也试过file_put_contents(),但结果相同我怎样才能解决这个问题?

编辑

因为$_POST['code']; exit()我也得到相同的输出

php

5
推荐指数
1
解决办法
148
查看次数

在 Visual Studio Code 中,有没有办法将设置和键绑定范围限定为语言模式?

VS Code中,我知道您可以创建包含全局用户键绑定和设置的文件,并且可以拥有用于键绑定和设置的工作区特定文件,但是是否可以定义特定于语言模式的设置或键绑定?

例如,我希望Alt+/表示FSI: Send Line当我处于 F# 模式时,而不是当我处于 Markdown 模式或 JS 模式时。

当我处于 Elm 模式时,我希望制表符为 2 个空格,但在 C# 模式下为 4 个空格。

我知道您可以使用when如下子句定义键绑定:

{
    "key": "alt+/",
    "command": "fsi.SendLine",
    "when": "resourceLangId == fsharp"
}
Run Code Online (Sandbox Code Playgroud)

这是实现我所追求的目标的唯一方法吗?

似乎能够在自己的文件中的某处定义模式 X 的设置/键绑定是有意义的。我不喜欢将语言模式行为分散在像这样的大型全局文件中。

keyboard-shortcuts visual-studio-code

5
推荐指数
2
解决办法
1574
查看次数

google-sheets api 未触发 google 表格中的 onEdit 功能

我正在使用 php 将数据写入谷歌表格。但是,当数据从 php.ini 写入时,Google Sheets 上的触发器 onEdit 函数不会触发。这是我用来写下数据的代码:

$body = new Google_Service_Sheets_ValueRange(array('values' => $resultArrayGen));
$params = array('valueInputOption' => $valueInputOption);
$range = 'Main!F2:K';
$result = $service->spreadsheets_values->update($spreadsheetId, $range, $body, $params);
Run Code Online (Sandbox Code Playgroud)

无论如何,有没有使用谷歌服务表API来触发谷歌电子表格中的onEdit功能?

谢谢

php google-sheets google-sheets-api

5
推荐指数
1
解决办法
1562
查看次数

VSCode:如何撤消分屏并仅显示当前文件?

VSCode 提供了用于操作(拆分和重新排列)屏幕的甜蜜快捷方式:

  1. Ctrl+\将屏幕一分为二。
  2. Ctrl+Number聚焦在其中一个屏幕上
  3. Ctrl+ Shift+0更改垂直/水平分割

但是,如何删除所有分屏并仅显示当前聚焦的分屏?

例如:说,我按Ctrl+\两次(给我三个垂直屏幕),然后按Ctrl+2选择中间屏幕。我现在应该按什么让左右屏幕消失,中间屏幕占据整个空间?在 Emacs 中,这将是Ctrl+ X+ 1

keyboard-shortcuts visual-studio-code

5
推荐指数
3
解决办法
6111
查看次数

使用curl将文件推送到GitHub存储库

我想在没有工具的情况下在 GitHub 存储库上创建(推送)新文件git(因为该git工具在我的主机上不可用PHP)。所以我做了一些研究,发现了GitHub REST API

我尝试使用curl个人访问令牌来上传或修改我的存储库上的文件。这是我找到的 shell 代码,并进行了curl如下更改:

curl -i https://api.github.com/repos/username/repo/newFile.txt -X PUT 
\ -H 'Authorization: token xxxxxxxxxxxxxxxxxxxx' -d "{\"path\": \"newFile.txt\", 
\ \"message\": \"update\", \"content\": \"$(openssl base64 -A -in newFile.txt)\", \"branch\": 
\"master\",
\ \"sha\": $(curl -X GET https://api.github.com/repos/username/repo/newFile.txt  | jq .sha)}" 
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

HTTP/1.1 404 未找到

服务器:GitHub.com

我该如何解决这个问题?

PS 即使push file by emailGitHub 或 (GitLab) 上有服务,这也可以帮助通过电子邮件在我的存储库上创建文件。

curl github-api github-pages gitlab-api

5
推荐指数
1
解决办法
3466
查看次数

Delphi应用程序主表单暂时轻弹到前面

我们有一个Delphi 2007应用程序,并且最近启用了MainFormOnTaskBar以更好地支持Windows Aero.但是,因为单击时主窗体不会出现在所有子窗体的顶部,所以我们添加了以下代码.

procedure TBaseForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);

  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent := 0; 
end;
Run Code Online (Sandbox Code Playgroud)

这样做的一个副作用是当在不处理该特定热键的子表单上按下Alt+ key热键时,主表单向前轻弹然后再向后.如果处理热键,则不会发生此行为,可能是因为吞下了热键.

有没有其他人经历过这种行为,可以建议一个解决方法.

谢谢

delphi user-interface hotkeys aero

4
推荐指数
1
解决办法
189
查看次数

java.lang.OutOfMemoryError:分配失败

所以我用 viewPager 做了一个活动,好吧,它一viewPager.setAdapter工作就崩溃了。这是崩溃日志。

java.lang.OutOfMemoryError: Failed to allocate a 26488162 byte allocation with 16777216 free bytes and 24MB until OOM
                  at java.lang.StringFactory.newStringFromChars(Native Method)
                  at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:629)
                  at java.lang.StringBuffer.toString(StringBuffer.java:723)
                  at java.io.StringWriter.toString(StringWriter.java:100)
                  at android.util.Log.getStackTraceString(Log.java:345)
                  at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:61)
                  at com.android.internal.os.RuntimeInit.-wrap0(RuntimeInit.java)
                  at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:86)
                  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
Run Code Online (Sandbox Code Playgroud)

这是活动的班级

public class SetupActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setup);
        ViewPager setupPager = (ViewPager) findViewById(R.id.setupViewpager); 
        SetupPagerAdapter setupPagerAdapter = new SetupPagerAdapter(getSupportFragmentManager());    
        setupPager.setAdapter(setupPagerAdapter);
   }
}
Run Code Online (Sandbox Code Playgroud)

这是SetupPagerAdapter

public class SetupPagerAdapter extends FragmentPagerAdapter {
    public SetupPagerAdapter(FragmentManager …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments

4
推荐指数
1
解决办法
1万
查看次数

搜索类 PhpStorm 中的方法

我曾经在 Eclipse 中工作,有一个非常简洁的热键 ( Ctrl+ O),用于搜索类中的方法。

我的意思是,如果您在编辑器中查看类的源代码,并且点击Ctrl+ O,则会弹出一个列出所有方法的窗口。如果您开始输入,该列表将被过滤。如果我输入get,我可以看到一个 getter 列表..

这非常有帮助。我转向了 PHP 和 PhpStorm,在这里我很想念这个功能,或者我不知道 PhpStorm 是否有这个功能。

你们对 PhpStorm 中的这样一个关键组合有任何想法吗?

keyboard-shortcuts phpstorm

4
推荐指数
1
解决办法
1067
查看次数

如何在Application.OnKey中使用方括号?(Excel VBA)

我想使用组合键Shift+ Alt+ [来调用我的VBA项目中的子程序.这是我尝试过的代码:

Appication.OnKey "+%[", "mySubroutine"
Run Code Online (Sandbox Code Playgroud)

我使用shift和alt的其他字符没有问题,例如小写字母和数字.但是,当我尝试使用左方括号时,我收到以下错误:

Method 'OnKey' of object '_Application' failed
Run Code Online (Sandbox Code Playgroud)

我也曾尝试使用左方括号与所有不同的组合Ctrl,AltShift.它们都会产生相同的错误.

Application.OnKey "^[", "mySubroutine"
Application.OnKey "+[", "mySubroutine"
Application.OnKey "%[", "mySubroutine"
Application.OnKey "^+[", "mySubroutine"
Application.OnKey "^%[", "mySubroutine"
Application.OnKey "^+%[", "mySubroutine"
Run Code Online (Sandbox Code Playgroud)

我也尝试使用左方括号(91)的ASCII代码,如下所示:

Application.OnKey "+%{91}", "mySubroutine"
Run Code Online (Sandbox Code Playgroud)

没有运气.

我也尝试使用Excel的内置Chr()函数和ASCII密钥代码:

Application.OnKey "+%" & Chr(91), "mySubroutine"
Run Code Online (Sandbox Code Playgroud)

哪个也行不通.

我正在运行Excel 2013.我们办公室中的另一台计算机运行的是Excel 2003,虽然该计算机使用的是Excel4Macro语言,但它可以使用左方括号来设置键盘快捷键.

似乎Microsoft在较新版本的Excel中删除了此功能.但是,如果有人能想出办法让它发挥作用,我将不胜感激!

excel vba keyboard-shortcuts hotkeys excel-vba

3
推荐指数
1
解决办法
455
查看次数

为什么 java.net.HttpURLConnection 变成了 sun.net.www.protocol.http.HttpURLConnection?

我有一个这样的代码:

HttpURLConnection connection = (HttpURLConnection) loginUrl.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36");
connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestProperty("Referer", "http://www.icourse163.org/member/logout.htm");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);

OutputStream out = connection.getOutputStream();
Run Code Online (Sandbox Code Playgroud)

我的连接是 HttpURLConnection 的一个实例,但是当我调试代码时。当代码运行到OutputStream out = connection.getOutputStream();.I时, 我看到getOutputStream()sun.net.www.protocol.http.HttpURLConnection的方法。为什么?

java

3
推荐指数
1
解决办法
4890
查看次数