我有一个 html 表单,访问者可以在其中填写一些信息并将其作为电子邮件发送给我。它像这样发送:
$body = print_r($_POST, true);
mail ($to, $subject, $body, $headers);
当他们写 abc'def 我得到 abc\'def
这个额外的 \
是什么?我该如何预防?
最佳答案
因为魔法引号。参见 here .
它们没有输出不同的东西——$_POST
超全局变量已经有了反斜杠。
关于php - PHP 中的 print_r() 和 mail() 输出不同的东西,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3063964/