PHP从引号输出
我定期使用类似的表单,并且刚刚意识到,每当在表单中输入单引号或双引号时,给我自己的输出(通过电子邮件)都会将引号显示为 ASCII 代码,因此 \' 带有反斜杠 ive环顾四周并深入研究独特的字符编码专业,但似乎找不到任何有助于将其输出为正常引号的内容。
I use a similar form on a regular basis and have just become aware that whenever a single OR double quotation mark is inputted into the form the output to myself (through email) displays the quotation mark as the ASCII code so \' with a backslash ive looked around and dipped into unique character encodings specialentities but cant seem to find anything that will help output it as a normal quotation mark.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是
magic_quotes_gpc
长期弃用的古老 PHP 设置。把它关掉
it is
magic_quotes_gpc
long-time deprecated ancient PHP setting.just turn it off
这是 PHP 的一个古老的安全功能,称为“Magic Quotes”。 GET 和 POST 变量的所有引号都用反斜杠转义。
您可以通过将服务器 php.ini 中的
magic_quotes_gpc
值更改为off
来禁用它,或者使用stripslashes($string)
手动清理字符串。It is an old security feature from PHP called "Magic Quotes". All Quotes from GET- and POST varables are escaped with the backslash.
You can disable it by changing the value of
magic_quotes_gpc
tooff
in your servers php.ini or manually sanitize the strings usingstripslashes($string)
.您使用什么版本的 PHP?听起来您可能启用了魔术引号,这是一个已弃用的“功能”,它会自动在
$_GET
和$_POST
中的引号中添加反斜杠。现在使用它被认为是不好的做法,所以你应该确保它被禁用。请参阅此页面了解如何检查它是否已启用和禁用它。一般来说,如果您有一个带有转义引号的字符串,您可以使用
stripslashes
来删除它们。What version of PHP are you using? It sounds like you may have magic quotes enabled, a deprecated "feature" that automatically adds backslashes to quotes in
$_GET
and$_POST
. It is considered bad practice nowadays to use it, so you should make sure it's disabled. See this page for how to check if it's enabled and disable it.In general, if you have a string with escaped quotes, you can use
stripslashes
to get rid of them.