在 PHP 中回显 $_POST

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3002165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:22:59  来源:igfitidea点击:

Echo an $_POST in PHP

phphttp-post

提问by Victor Bjelkholm

How can I print a $_POST?

我怎样才能打印一个$_POST

Example:

例子:

echo $_POST['data'];

This returns nothing...

这什么都不返回...

回答by Jamex

You can also wrap your code with <pre>tags to make your array prints out nicer instead of just 1 continuous line. A trick that was shown by a member on this site.

您还可以用<pre>标签包装您的代码,以使您的数组打印效果更好,而不仅仅是 1 条连续线。由本网站的成员展示的技巧。

<pre>
<?php var_dump($_POST); ?>
</pre>

回答by Tim Ridgely

Your code is correct.

你的代码是正确的。

You can use either:

您可以使用:

var_dump($_POST);

or

或者

print_r($_POST);

to print out the entire POST array for debugging.

打印出整个 POST 数组以进行调试。

回答by Ignacio Vazquez-Abrams

You can only show the values of keys that exist. array_keys()returns an array containing the keys that exist in the array. If there is no output for a key despite the fact that the key exists then the array may contain an empty value for that key.

您只能显示存在的键的值。array_keys()返回一个包含数组中存在的键的数组。如果尽管键存在但没有键的输出,则数组可能包含该键的空值。