使用空格发布隐藏字段会删除空格后的内容

时间:2013-09-20 08:17:16

标签: javascript php post hidden-field

发布隐藏字段,例如value:'这是示例格式'。 在$ _POST ['name']中获得结果时,变量的值将减少为'this'。 这意味着去除了whitepsace之后的一切...... 有什么想法吗?

PS我在隐藏字段的值上使用htmlspecialchars来替换带有格式化数据的空格,但它没有帮助。

PSS我认为这是我自己的错,因为在网上没有任何关于它的信息,所以很可能没有解决方案。

2 个答案:

答案 0 :(得分:0)

猜猜你必须在你的“价值”中逃避引用:"\"

答案 1 :(得分:-1)

我似乎无法重现您的错误。你可以发布你的表单代码,也许还有其他错误吗?

无论我尝试什么,我都得到了一个好结果,例如:

<form method="post" action="./test.php">
<input type="hidden" value="<?=htmlspecialchars('this is the format')?>" name="test" />
<input type="submit" />
</form>

// Blah blah code, then result    
echo $_POST['test']; // gives this is the format

另一方面,编码AFTER post,给出OK结果。

<form method="post" action="./test.php">
<input type="hidden" value="this is the format" name="test" />
<input type="submit" />
</form>

// Blah blah code, then result    
echo htmlspecialchars($_POST['test']); // gives this is the format