首页 > php > PHP $ _POST删除反斜杠

PHP $ _POST删除反斜杠 (PHP $_POST Removing Backslash)

问题

我正在提交一份包含以下内容的表单:

This is a test \ or something

最终通过POST进入

This is a test  or something

注意缺少反斜杠。我真的需要保持反斜杠的内容。任何帮助都是极好的。

编辑:

基本上我只是把它写到文件中:

<?php

frwite($file, $_POST['content']);

?>

我没有对它或任何其他转换运行stripslashes()

它在启用了magic_quotes_gpc的服务器上正常工作,但是这个应用程序可能在支持的服务器和不支持的服务器之间浮动。

基本上我正在寻找一种方法来使这项工作无论magic_quotes_gpc如何

解决方法

在代码中的某处,您可能正在调用stripslashes()。检查您的代码是否没有此功能以及您可能包含的任何其他库。

问题

I'm submitting though a form with content like this:

This is a test \ or something

Which ends up coming through POST as

This is a test  or something

Notice the missing backslash. I really need the contents with the backslash maintained. Any help would be awesome.

EDIT:

Basically I'm just writing this out to a file:

<?php

frwite($file, $_POST['content']);

?>

I'm not running stripslashes() against it or any other transformations

It works fine on a server with magic_quotes_gpc enabled, but this application may float between servers that support and some that don't.

Basically I'm looking for a way to make this work regardless of magic_quotes_gpc

解决方法

Somewhere in your code you might be calling stripslashes(). Check that your code doesn't have this function and any other libraries you may have included.

相似信息