【问题标题】:How can I use ' without slash?如何使用 ' 不带斜线?
【发布时间】:2016-01-21 07:02:26
【问题描述】:

我想将一个包含单引号的输入框发布到一个 php 文件中。我使用了 ' 但它发送了一些反斜杠:

<input type="hidden" name="legal_natural" value="$store_info[&#39;legal_natural&#39;]">

结果:

$store_info[\'legal_natural\']

请告诉我在将 ' 发布到 PHP 文件时如何避免反斜杠?

【问题讨论】:

    标签: php html single-quotes


    【解决方案1】:

    看到这个:SO Question

    这是该问题的答案:

    假设您想要发送$content 变量而不是仅仅剥离反斜杠,考虑使用urlencode() 而不是rawurlencode()。此外,您可以对 $content 变量使用该函数一次。

    $content = urlencode($content);
    

    更新:urlencode 和 rawurlencode 可能都不适合您的情况。为什么不直接发送没有 URL 编码的 $content 呢?您如何发送我们的查询字符串?如果您使用 cURL,则不需要对参数进行编码。

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 2010-10-06
      • 2017-01-14
      • 1970-01-01
      • 2021-12-18
      • 2013-03-29
      • 2017-11-02
      • 2012-05-18
      • 1970-01-01
      相关资源
      最近更新 更多