为什么 htmlspecialchars 在我的网页上添加斜杠?

发布于 2024-09-05 14:55:05 字数 180 浏览 4 评论 0原文

我通过 PDO 准备好的语句将输入放入 mySQL 中,并使用 htmlspecialchars() 将其放入我的网站中,以防止 XSS。唯一的问题是现在我在任何引号之前得到斜杠,这些斜杠在网页上对用户可见只有当我将其上传到服务器时才会发生。在我的本地主机上永远不会发生。

为什么会发生这种情况?

I have my input placed into mySQL through a PDO prepared statement, and have it placed in my website with PHP using htmlspecialchars() to protect against XSS. Only problem is now I get slashes, before any quotes, that are visible on the webpage to the user it only happens when I upload it to the server. Never happens on my localhost.

Why is this happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明媚如初 2024-09-12 14:55:06

服务器启用了魔术引号吗?

在 PHP 中尝试这一行来找出:

if(get_magic_quotes_gpc())
    echo "Magic quotes are enabled";
else
    echo "Magic quotes are disabled";

如果它们已启用,您可以使用 stripslashes 删除它们。

The server has magic quotes enabled?

Try this line in PHP to find out:

if(get_magic_quotes_gpc())
    echo "Magic quotes are enabled";
else
    echo "Magic quotes are disabled";

If they are enabled, you can use stripslashes to remove them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文