%22(双引号)无处不在地添加到url中

Daa*_*nvn 4 php url tinymce

我正在制作一个邮件程序,用于向客户邮寄新闻通讯,在新闻通讯中将是图像和链接.当我在localhost上测试它时,一切正常,链接工作正常.但是,当我将其上传到我的网站时,链接和图像路径将不再起作用.

出于某种原因,它将%22(我发现它是双引号")添加到链接和路径,因此我邮寄的链接如下所示:

/%22http//www.mywebsite.com/%22

图像路径如下所示:

%22http//www.mywebsite.com/content/someimage.jpg/%22

我正在使用TinyMCE来编辑时事通讯,我已经尝试过relative_urls : false,convert_urls : false但这没有任何作用.我不认为这是一个TinyMCE问题,但我认为无论如何我都会提到它.

我不知道造成这种情况的原因所以如果有人知道它会发生什么就会很棒!

更新:我已经检查了我的代码并查看了邮件中发送的文本的html,并且链接周围没有双引号,所以我的猜测是它是服务器问题.

Kee*_*ema 5

这是magic_quotes检查您的phpinfo()以查看它是否已关闭的问题.如果你能把它关闭你必须在你的php.ini中禁用它.

您可以使用以下代码测试它是启用还是禁用:

<?php
echo "Magic quotes is ";
if (get_magic_quotes_gpc()) {
  echo "enabled.";
} else {
  echo "disabled";
}
?>
Run Code Online (Sandbox Code Playgroud)

另一个修复可能是stripslashes()用于删除斜杠.这很可能会解决问题.

阅读有关HERE的文档stripslashes()

一个简单的例子:

<?php
$str = "Is your name O\'reilly?";

// Outputs: Is your name O'reilly?
echo stripslashes($str);
?>
Run Code Online (Sandbox Code Playgroud)

编辑:你可以尝试的另一件事是使用html_entity_encode().

一个例子:

<?php
$orig = "I'll \"walk\" the <b>dog</b> now";

$a = htmlentities($orig);

$b = html_entity_decode($a);

echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now

echo $b; // I'll "walk" the <b>dog</b> now
?>
Run Code Online (Sandbox Code Playgroud)

信息在这里

另一个SO答案.为html_entity_encode()在URL中 /sf/answers/700070451/

  • 因为他添加了php标签. (2认同)