Home >Backend Development >PHP Problem >How to determine whether Radio is selected in PHP?

How to determine whether Radio is selected in PHP?

Guanhui
GuanhuiOriginal
2020-06-04 18:15:513828browse

How to determine whether Radio is selected in PHP?

#How does PHP determine whether Radio is selected?

First set the value of the Radio element to 1;

Then receive the requested data in the PHP code;

Then determine whether there is any in the received data Radio data, if it exists, select it;

$data = $_POST;

if (isset($data['radio_name'])) {
  //选中
} else {
    //未选中
}

Finally determine whether the selected value is the set value, if not, it is not selected.

$data = $_POST;

if (isset($data['radio_name'] && $data['radio_name'] == 1)) {
  //选中
} else {
    //未选中
}

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to determine whether Radio is selected in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn