获取PHP中的Submit按钮的名称 [英] Get the name of submit button in PHP
本文介绍了获取PHP中的Submit按钮的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取PHP中提交按钮的名称?
How do I get the name of the submit button in PHP?
我知道了提交按钮的价值,但我找不到 获取按钮名称的任何代码.下面是我编写的代码.
I got the value of submit button, but I could not find any code to get the name of the button. Below is the code I have written.
<form name="form1" method="post">
<input type="submit" value="hello" name="submitbutton">
</form>
<?php
echo "Value of submit button: " . $_POST['submitbutton'];
echo "Name of submit button: " . // What should I do here? //;
?>
推荐答案
您将在$ _POST数组中找到该名称.
You will find the name in the $_POST array.
<?php
print_r($_POST);
?>
这样,您将在$ _POST数组中看到所有内容.
This way you will see everything in the $_POST array.
您可以使用以下方法遍历数组:
You can iterate through the array with:
foreach($_POST as $name => $content) { // Most people refer to $key => $value
echo "The HTML name: $name <br>";
echo "The content of it: $content <br>";
}
这篇关于获取PHP中的Submit按钮的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文