繁体   English   中英

表单发布将“(双引号)替换为”

[英]Form post replaces " (double quotes) with "

我在本地服务器上开发。 当我将页面上传到网站时,我遇到了这个问题。 它在我的本地服务器(WAMP)上不会发生。

 <form  class='form-horizontal' method='post' id='uparticle'>

...

<textarea class='form-control <?php echo $cked ?>' name='editor1' id='editor1' rows='10' cols='80'>
      <?php echo $article; ?>
      </textarea>

当我提交表单时,它用"替换为\\&quot;我使用了ckeditor,但事实并非如此,因为我也在文本数据字段中发送了$ article而不使用ckeditor。

我还通过在将文本数据写入数据库之前显示文本数据来消除数据库写入。

例如: <table border="1" cellpadding="2" cellspacing="0">被重写为<table border="\\&quot;1\\&quot;" cellpadding="\\&quot;2\\&quot;" cellspacing="\\&quot;0\\&quot;"> <table border="\\&quot;1\\&quot;" cellpadding="\\&quot;2\\&quot;" cellspacing="\\&quot;0\\&quot;">

我认为这可能是一些配置设置,但是我不知道在哪里看。

您需要使用htmlspecialchars_decode将特殊的HTML实体转换回字符

例如:

<?php
$str = "<p>this -&gt; &quot;</p>\n";

echo htmlspecialchars_decode($str);

// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>

上面的示例将输出:

<p>this -> "</p>
<p>this -> &quot;</p>

并在您的HTML代码中使用此meta标签:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

如果您使用的是旧PHP版本(即5.3),则可能是magic_quotes_gpc设置引起的。 检查php.ini中的设置,并将其值设置为“ 0”。 还要检查其他magic_quotes设置,您也可以将其关闭。

有关更多信息,请访问http://php.net/manual/zh/info.configuration.php#ini.magic-quotes-gpc

暂无
暂无

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

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