gpt4 book ai didi

php - 一个斜杠在 cotation 之后添加到字符串中 - PHP

转载 作者:太空宇宙 更新时间:2023-11-03 12:34:53 25 4
gpt4 key购买 nike

为了将字符串插入数据库,我在字符串上应用了这个函数:

$string = strip_tags($string);
$string = htmlspecialchars($string);
$string = preg_replace('/\s+/', ' ', $string); // removing multiple spaces :-)
$string = preg_replace('/(?:\s\s+|\n|\t)/', ' ', $string);
$string = mysql_real_escape_string($string);

在我测试应用程序时,我在本地主机上输入:Life's Interesting

并将确切的字符串保存到 db(Life's Interesting)中,然后我将我的应用程序上传到真实服务器上,当我输入相同的字符串时,它会在数据库中保存:Life\'s Interesting!

为什么这种情况只发生在服务器上而不发生在我的本地主机上?我在本地主机上使用 Wamp。我需要在服务器上更改什么配置才能正确保存在数据库中?

提前致谢

最佳答案

因为magic_quotes_gpc

var_dump(magic_quotes_gpc())

var_dump magic 在你的两个服务器中引用 gpc。你的真实服务器我认为魔术引号是默认启用的。

Magic Quotes is a process that automagically escapes incoming data to the PHP script. It's preferred to code with magic quotes off and to instead escape the data at runtime, as needed.

阅读更多 PHP Manual - Magic Quotes

关于php - 一个斜杠在 cotation 之后添加到字符串中 - PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13621970/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com