Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
简单的问题。我有一个使用 AJAX 将数据从 HTML 表单发送到创建 PDF 的 PHP 脚本的程序。如果用户在 HTML 表单上输入一个带有撇号的值,它会用反斜杠进行编码/转义。例如,'Joe's' 变成 'Joe\s'
如何删除反斜杠?我想我可以使用 str_replace('\', '', $input) 但我想知道在 PHP 中“取消转义”字符串的更广泛方法是什么。
正常使用 Ajax 不会在数据中添加斜线字符。
它们最有可能的来源是魔术引号(这是邪恶的)。把它们关掉。
只需使用 stripslashes($input);
stripslashes($input);