0

我发布了一个隐藏字段,例如值:“这是示例格式”。在 $_POST['name'] 中获取结果时,变量的值被缩减为只有 'this'。这意味着删除空白后的所有内容..有什么想法吗?

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

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

4

2 回答 2

0

猜猜你必须转义引号:"\"你的“价值”之内。

于 2013-09-20T08:36:39.847 回答
-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

另一种方式,在发布后编码,给出好的结果。

<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
于 2013-09-20T08:24:54.687 回答