Get the value of the radio button in the form in the php code: (The radio button can only allow us to select one. There is a "checked" attribute here, which is used to select it by default. Every time we refresh our page It defaults to this value.)
Example:
Gender:
男女
If you select male, the value that comes out will be "male". is female, the value that comes out is "female".
Get the value of the check box in the php code: (The check box allows us to select multiple times. They exist at the same time. In order to facilitate the transfer of values, we set the name to an array.)
The format is:
Method: Use the count() function to calculate the size of the array in the return page, and combine it with a for loop statement to output the value of the selected check box.
Example:
Your favorite number:
1 2 3 4
We have to learn to use arrays to solve our problems! ! ! !
The above is the detailed content of How to get the values of radio buttons and check buttons in php form (example). For more information, please follow other related articles on the PHP Chinese website!