【问题标题】:How to output the value of the quotes in the input?如何输出输入中引号的值?
【发布时间】:2013-02-15 21:19:59
【问题描述】:

我有代码

$name = 'Test world \"Example\" end';
<input type="text" name="text"  value="'.$name.'">

但在输入页面上的输入中,我只看到Test world \

在 furebug 中,我在输入中看到了完整的代码:

<input type="text" name="text"  value="Test world "Example" end">

结果我看到该报价比必要的更早关闭。

请告诉我如何做出正确的结果(结果应该带有引号)?

【问题讨论】:

  • htmlencode/htmlspecialchars
  • 为什么你使用 \" 而不仅仅是 " ?因为您使用了单配额 ' 然后不需要转义双配额
  • 或者直接使用&amp;quot;,它会为你输出报价。
  • 以及如何删除slash

标签: php input output


【解决方案1】:
$name = 'Test world \"Example\" end';
echo '<input type="text" name="text"  value="'.htmlspecialchars($name,ENT_QUOTES).'">';

【讨论】:

    【解决方案2】:

    $name = 'Test world \\"Example\\" end'; <input type="text" name="text" value="'.$name.'">

    要么这样,要么对这些斜线进行编码。

    【讨论】:

      猜你喜欢
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多